Chris, I can't replicate that. What versions of R, data.table, and plyr
are you using?

As an aside, why do you need ddply in the first place? It seems
data.tables would be faster for that sort of thing.

- Tom


 

> -----Original Message-----
> From: [email protected] 
> [mailto:[email protected]] On 
> Behalf Of Chris Neff
> Sent: Thursday, August 04, 2011 18:13
> To: [email protected]
> Subject: [datatable-help] IDate somehow gets converted to numeric?
> 
> This was kind of hard to track down. An example:
> 
> > DT <- data.table(date=as.IDate(rep("2010-01-01",10)),x=1:10)
> 
> > DT <- as.data.frame(DT)
> 
> > str(DT)
> 'data.frame':   10 obs. of  2 variables:
>  $ date:Classes 'IDate', 'Date'  int [1:10] 14610 14610 14610 
> 14610 14610 14610 14610 14610 14610 14610
>  $ x   : int  1 2 3 4 5 6 7 8 9 10
> 
> > DT2 <- ddply(DT, c("date", "x"), identity)
> 
> > str(DT2)
> 'data.frame':   10 obs. of  2 variables:
>  $ date:Classes 'IDate', 'Date'  num [1:10] 14610 14610 14610 
> 14610 14610 ...
>  $ x   : int  1 2 3 4 5 6 7 8 9 10
> 
> 
> As you can see int has changed to num here. If I try to 
> convert back to a data table and key on date again:
> 
> > DT2 <- as.data.table(DT2)
> > key(DT2)="date"
> Error in setkey("x", value) :
>   Column 'date' cannot be auto converted to integer without 
> losing information.
> 
> Whereas converting DT back to a data table and keying on date 
> works fine.  Bug?
> 
> -Chris
> _______________________________________________
> datatable-help mailing list
> [email protected]
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/d
atatable-help
> 
_______________________________________________
datatable-help mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help

Reply via email to