[R] How to read in dataframe from file

ripley@stats.ox.ac.uk ripley at stats.ox.ac.uk
Wed Mar 13 13:22:49 CET 2002


On Wed, 13 Mar 2002, Lukas Kubin wrote:

> I need to read in a dataframe stored in a cvs file. The problem is I don't
> know how to tell R the first column (in format like "7-Jan-80") is a
> vector of dates.
> Could you help me, please?

It seems unlikely to me that the dataframe is stored in a cvs file. (A
dataframe is an R object.)  So let me guess that you have a text file
stored under cvs, which you need to read into R.  The tool to do so is
read.table, and you should read the column as a character vector, then
call as.POSIXct(strptime()) on it, to convert it to a "POSIXct" date-time
column.

Had the column been in an ISO format you might be able to get away with
specifying the class to read.table() as "POSIXct" (you need the methods
package set up to do this) but it is not.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list