csv.get {Hmisc}R Documentation

Read Comma-Separated Text Data Files

Description

Read comma-separated text data files, allowing optional translation to lower case for variable names after making them valid S names.

Usage

csv.get(file, lowernames=FALSE, datevars=NULL, dateformat='%F',
        fixdates=c('none','year'), comment.char="", autodates=TRUE,
        allow=NULL, ...)

Arguments

file the file name for import.
lowernames set this to TRUE to change variable names to lower case.
datevars character vector of names (after lowernames is applied) of variables to consider as a factor or character vector containing dates in a format matching dateformat. The default is "%F" which uses the yyyy-mm-dd format.
dateformat for cleanup.import is the input format (see strptime)
fixdates for any of the variables listed in datevars that have a dateformat that cleanup.import understands, specifying fixdates allows corrections of certain formatting inconsistencies before the fields are attempted to be converted to dates (the default is to assume that the dateformat is followed for all observation for datevars). Currently fixdates='year' is implemented, which will cause 2-digit or 4-digit years to be shifted to the alternate number of digits when dateform is the default "%F" or is "%y-%m-%d", "%m/%d/%y", or "%m/%d/%Y". Two-digits years are padded with 20 on the left. Set dateformat to the desired format, not the exceptional format.
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.
... arguments to pass to read.csv.

Details

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. Character or factor variables containing dates can be converted to date variables. cleanup.import is invoked to finish the job.

Value

a new data frame.

Author(s)

Frank Harrell, Vanderbilt University

See Also

sas.get, data.frame, cleanup.import, read.csv, strptime, POSIXct, Date

Examples

## Not run: 
dat <- read.table('myfile.csv')
dat <- cleanup.import(dat)
## End(Not run)

[Package Hmisc version 3.0-10 Index]