[R] Reading Dates in a csv File
Frank E Harrell Jr
f.harrell at vanderbilt.edu
Thu Feb 3 16:47:42 CET 2005
Charles and Kimberly Maner wrote:
> Hi all. I'm reading in a flat, comma-delimited flat file using read.csv.
> It works marvelously for the most part. I am using the colClasses argument
> to, basically, create numeric, factor and character classes for the columns
> I'm reading in. However, a couple of the fields in the file are date
> fields. I'm fully aware that POSIXct can be used as a class, however the
> field must obey, (I think), the standard/default POSIXct format. Hence the
> following question: Does anyone have a method they can share to read in a
> non-standard formatted date to convert to POSIXct? I can read it in then
> convert it, but that's a two pass approach and not as elegant as a single
> pass through read.csv. I've read, from the documentation, that "[o]therwise
> there needs to be an as method (from package methods) for conversion from
> "character" to the specified formal class" but I do not know and have not
> figured out how to do that.
>
> Any suggestion(s) would be greatly appreciated.
>
>
> Thanks,
> Charles
The csv.get function in the Hmisc package may do most of what you want.
--
Frank E Harrell Jr Professor and Chair School of Medicine
Department of Biostatistics Vanderbilt University
More information about the R-help
mailing list