Import {car} | R Documentation |
Use the import
function from the rio package to read a data.frame from a variety of file types. The Import
function includes 3 additional arguments adding row names and for converting character and logical variables to factors.
Import(file, format, ..., row.names=TRUE, stringsAsFactors = default.stringsAsFactors())
file |
A character string naming a file, URL, or single-file .zip or .tar archive. See the details below. If the file name has an extention like |
format |
If an extension is not present in the file name or it is wrong, the file format can be set with this argument; see |
... |
Additional arguments passed to |
row.names |
If |
stringsAsFactors |
If |
This function always calls the import
function to read a data frame from a file. Many type of file are supported. The Import
function allows the user to set row.names
, and automatically convert character and logical variables to factors, but only if the format
of the file is one of "txt", "csv", "xlsx", "xls", "ods"
. Many more details are given at the man page for import
.
A data frame. See import
for more details
Sanford Weisberg sandy@umn.edu
head(Duncan, 3) # first three rows Export(Duncan, "Duncan.csv", keep.row.names="occupation") Duncan2 <- Import("Duncan.csv") # Automatically restores row.names and factors head(Duncan2, 3) # first three rows identical(Duncan, Duncan2) # cleanup unlink("Duncan.csv")