[R] parsing dates in input file

From: Tim Coote <t.coote_at_tideway.com>
Date: Thu, 13 Dec 2007 17:11:53 -0000


I've hunted around to try to work this out and cannot find anything aposite, although there are exhortations to read News files and the fine manual in response to similar queries. Hope I haven't missed anything obvious.  

I want to read in csv files that contain dates, or date times. If I read them in directly:
x <- read.csv ("file")

the relevant dataframe column is of type string. It would be nice to read in in one go, but not necessary. If I parse the data and then try to overwrite the original column of the data frame: y <- strptime (x$datefield, "%d/%m/%Y")
x$datefield <- y  

I get an error:
Error in `$<-.data.frame`(`*tmp*`, "datefield", value = list(sec = c(0, :
  replacement has 9 rows, data has 16  

y has 16 values, as does x$datefield.  

I'm sure that this is a common problem. Has anyone got any pointers?  

tia  

Tim
This email and any attachment may contain confidential, privileged information for the sole use of the intended recipient. If you are not the intended recipient, do not disclose, reproduce, disseminate or otherwise use this communication. If you received this communication in error, please immediately notify the sender via email and delete the communication from your system. Company information : Tideway Systems Ltd, Registered Office: Anchor House, 15-19 Britten Street, London, SW3 3TY. Registered in England & Wales Reg. Reg. No: 4598072 VAT No: 805 5153 50

        [[alternative HTML version deleted]]



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Thu 13 Dec 2007 - 17:17:08 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 13 Dec 2007 - 18:30:18 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.