[R] write.table read.table with Dates

JeeBee JeeBee at troefpunt.nl
Thu Nov 10 15:40:53 CET 2005


I see that strptime returns a list of
year, mon, mday, hour, min, sec, etc.

The following works for me (for each column that is a date/time field
in my imported file)

cat("Converting date/time fields...\n")
Q = strptime(as.character(data$myfield), format="%Y-%m-%d%H:%M:%S")
data$myfield = ISOdatetime(year = Q$year + 1900,
               month = Q$mon + 1, day = Q$mday,
               hour =Q$hour, min = Q$min, sec = Q$sec, tz = "")

ISOdatetime does return a vector, which is, I guess, what I want.
It is quite slow like this though, and I don't think it's the best way.




More information about the R-help mailing list