[R] Problem with ddply in the plyr-package: surprising output of a date-column

Hadley Wickham hadley at rice.edu
Mon Apr 25 22:07:41 CEST 2011


> If you need plyr for other tasks you ought to use a different
> class for your date data (or wait until plyr can deal with
> POSIXlt objects).

How do you get POSIXlt objects into a data frame?

> df <- data.frame(x = as.POSIXlt(as.Date(c("2008-01-01"))))
> str(df)
'data.frame':	1 obs. of  1 variable:
 $ x: POSIXct, format: "2008-01-01"

> df <- data.frame(x = I(as.POSIXlt(as.Date(c("2008-01-01")))))
> str(df)
'data.frame':	1 obs. of  1 variable:
 $ x: AsIs, format: "0"

Hadley

-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/



More information about the R-help mailing list