[R] POSIX turns into factor

Toby Gass tobygass at warnercnr.colostate.edu
Sat Oct 16 21:20:26 CEST 2010


Dear helpeRs,

I am working with a dataframe that includes a column, "calendar", 
used for plotting time series.

> class(dat$calendar)
[1] "POSIXt"  "POSIXlt"

When I finish working, I save my data as a .csv file.  When I read 
the file in again, "calendar" is always a factor

> class(dat$calendar)
[1] "factor"

and I have to turn it back into a date-time object.

Is this unavoidable when going back and forth from a .csv, or can I 
do something differently to retain the class?

R 2.11.1 on Windows OS.

Thank you.

Toby



More information about the R-help mailing list