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

Tom Short tshort.rlists at gmail.com
Mon Aug 8 23:08:59 CEST 2011


That narrowed it done a lot. Thanks, Chris. It looks like we need a
"[<-.IDate"  function. You can use the following locally until we can
get data.table updated.

"[<-.IDate" <-  function(x, ...) {
        as.IDate(NextMethod())
}

Let me know if that doesn't fix it for you. Please also check to see
if this fixes the ddply issue.

- Tom

On Mon, Aug 8, 2011 at 8:17 AM, Chris Neff <caneff at gmail.com> wrote:
> 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
> _______________________________________________
> datatable-help mailing list
> datatable-help at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help
>


More information about the datatable-help mailing list