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

From: Peter Ehlers <ehlers_at_ucalgary.ca>
Date: Mon, 25 Apr 2011 14:22:06 -0700

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



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 Mon 25 Apr 2011 - 21:33:02 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 Mon 25 Apr 2011 - 21:40:34 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.

list of date sections of archive