Read Comma-Separated Text Data Files
Read comma-separated text data files, allowing optional translation
to lower case for variable names after making them valid S names.
There is a facility for reading long variable labels as one of the
rows. If labels are not specified and a final variable name is not
the same as that in the header, the original variable name is saved as
a variable label. Uses read.csv
if the data.table
package is not in effect, otherwise calls fread
.
csv.get(file, lowernames=FALSE, datevars=NULL, datetimevars=NULL, dateformat='%F', fixdates=c('none','year'), comment.char="", autodates=TRUE, allow=NULL, charfactor=FALSE, sep=',', skip=0, vnames=NULL, labels=NULL, ...)
file |
the file name for import. |
lowernames |
set this to |
datevars |
character vector of names (after |
datetimevars |
character vector of names (after |
dateformat |
for |
fixdates |
for any of the variables listed in |
comment.char |
a character vector of length one containing a single character or an empty string. Use '""' to turn off the interpretation of comments altogether. |
autodates |
Set to true to allow function to guess at which variables are dates |
allow |
a vector of characters allowed by R that should not be converted to periods in variable names. By default, underscores in variable names are converted to periods as with R before version 1.9. |
charfactor |
set to |
sep |
field separator, defaults to comma |
skip |
number of records to skip before data start. Required if
|
vnames |
number of row containing variable names, default is one |
labels |
number of row containing variable labels, default is no labels |
... |
arguments to pass to |
csv.get
reads comma-separated text data files, allowing optional
translation to lower case for variable names after making them valid S
names. Original possibly non-legal names are taken to be variable
labels if labels
is not specified. Character or factor
variables containing dates can be converted to date variables.
cleanup.import
is invoked to finish the job.
a new data frame.
Frank Harrell, Vanderbilt University
## Not run: dat <- csv.get('myfile.csv') # Read a csv file with junk in the first row, variable names in the # second, long variable labels in the third, and junk in the 4th row dat <- csv.get('myfile.csv', vnames=2, labels=3, skip=4) ## End(Not run)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.