[datatable-help] IDate goes from int to num (easier example this time, and does not rely on plyr).

Chris Neff caneff at gmail.com
Mon Aug 8 14:17:42 CEST 2011


Hi all,

Using the latest 1.6.4 with type="source" from R-Forge.  The issue
seems to be with rbind on a data frame. Here's what happens:

> DT <- data.frame(x=as.IDate(rep("2010-01-01",10)), y=1:10)
> str(DT)
'data.frame':	10 obs. of  2 variables:
 $ x:Classes 'IDate', 'Date'  int [1:10] 14610 14610 14610 14610 14610
14610 14610 14610 14610 14610
 $ y: int  1 2 3 4 5 6 7 8 9 10
> str(rbind(DT, DT))
'data.frame':	20 obs. of  2 variables:
 $ x:Classes 'IDate', 'Date'  num [1:20] 14610 14610 14610 14610 14610 ...
 $ y: int  1 2 3 4 5 6 7 8 9 10 ...

If I take rbind(DT, DT), make it into a data table, and try to set the
key as x, it gives an error that x cannot be converted into integer
without losing some information.  That is because as you see from the
str calls above, x turns from "Classes 'IDate', 'Date' int" to
"Classes 'IDate', 'Date' num".

Note that rbind(data.table(DT), data.table(DT)) works fine.  So it is
the interaction between IDate and rbind.data.frame. Tried skimming
rbind.data.frame for any obvious things that stick out, but that is a
pretty inscrutable function.

Thoughts?
-Chris


More information about the datatable-help mailing list