[datatable-help] Can crash R with a data.table query

mdowle at mdowle.plus.com mdowle at mdowle.plus.com
Thu Jul 1 11:32:53 CEST 2010


What you mean by 'crash'? R simply stops or theres a message?
Try the clean install of latest 1.5, as per recent reply on other thread,
and can go from there...

> Hi,
>
> I am crashing R with the following code (and it might have something to do
> with data tables as well):
>
> =========
>
>
> DT <- structure(list(A = c(25L, 85L, 25L, 25L, 85L), B = structure(c(1L,
> 1L, 2L, 3L, 3L), .Label = c("a", "b", "c"), class = "factor"),
>     C = c(2L, 65L, 9L, 82L, 823L)), .Names = c("A", "B", "C"), class =
> c("data.table",
> "data.frame"), row.names = c(NA, -5L))
>
> DT[ , data.table( A, C )[ A==25, C ] + data.table( A, C )[ A==85, C ],
> by=B ]
>
> =========
>
> For every B, I am trying to sum the C's where A is 25 and 85.
>
> The crash has something to do with my row selection criteria.  First, note
> that for B=="b", I don't have A==85.  It looks like a numeric(0) is being
> returned in this case.
>
> In order to avoid the crash, I had to do something like:
>    if ( ! identical( DT[ blah ], numeric( 0 ) )
>
> It isn't just that R is unable to handle operations on numeric(0) because
> I don't get a crash when I just type in "numeric(0) + 2".  So, my guess is
> that it has something to do with data.table as well.
>
>
> Harish
>
>
>
>
> _______________________________________________
> 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