Problem with ddply in the plyr-package: surprising output of a date-column
On 2011-04-25 13:07, Hadley Wickham wrote:
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
To mimic the OP's code df <- data.frame(x = "2008-01-01") df$x <- as.POSIXlt(df$x, "%Y-%m-%d") str(df) #'data.frame': 1 obs. of 1 variable: # $ x: POSIXlt, format: "2008-01-01" Peter Ehlers