[datatable-help] Possible bug in 1.9.x versions

carrieromichele carrieromichele at gmail.com
Thu Feb 27 16:05:07 CET 2014


I just installed the new data.table versions. I tried both 1.9.0, available
(binary) at http://datatable.r-forge.r-project.org/data.table_1.9.0.zip,
and 1.9.2 (CRAN) building from source (using Rtools)

After installing I run my BAU scripts and found out that I had different
results... this is what I could made reproducible

1.8.10

> library(data.table)
data.table 1.8.10  For help type: help("data.table")
> set.seed(1)
> dt <- data.table(id=rep(1:4, each=3),
+                  var1 = rep(letters[1:3], 4),
+                  var2 = rnorm(12),
+                  key="id,var1")
> dt
    id var1       var2
 1:  1    a -0.6264538
 2:  1    b  0.1836433
 3:  1    c -0.8356286
 4:  2    a  1.5952808
 5:  2    b  0.3295078
 6:  2    c -0.8204684
 7:  3    a  0.4874291
 8:  3    b  0.7383247
 9:  3    c  0.5757814
10:  4    a -0.3053884
11:  4    b  1.5117812
12:  4    c  0.3898432
>
> key(dt)
[1] "id"   "var1"
> dt[.(unique(id)), list(var1, var2)]
    id var1       var2
 1:  1    a -0.6264538
 2:  1    b  0.1836433
 3:  1    c -0.8356286
 4:  2    a  1.5952808
 5:  2    b  0.3295078
 6:  2    c -0.8204684
 7:  3    a  0.4874291
 8:  3    b  0.7383247
 9:  3    c  0.5757814
10:  4    a -0.3053884
11:  4    b  1.5117812
12:  4    c  0.3898432

1.9.0


> library(data.table)
data.table 1.9.0  For help type: help("data.table")
Warning message:
package 'data.table' was built under R version 3.1.0
> set.seed(1)
> dt <- data.table(id=rep(1:4, each=3),
+                  var1 = rep(letters[1:3], 4),
+                  var2 = rnorm(12),
+                  key="id,var1")
> dt
    id var1       var2
 1:  1    a -0.6264538
 2:  1    b  0.1836433
 3:  1    c -0.8356286
 4:  2    a  1.5952808
 5:  2    b  0.3295078
 6:  2    c -0.8204684
 7:  3    a  0.4874291
 8:  3    b  0.7383247
 9:  3    c  0.5757814
10:  4    a -0.3053884
11:  4    b  1.5117812
12:  4    c  0.3898432
>
> key(dt)
[1] "id"   "var1"
> dt[.(unique(id)), list(var1, var2)]
    id var1       var2
 1:  1    a -0.6264538
 2:  1    a  0.1836433
 3:  1    a -0.8356286
 4:  2    a  1.5952808
 5:  2    a  0.3295078
 6:  2    a -0.8204684
 7:  3    a  0.4874291
 8:  3    a  0.7383247
 9:  3    a  0.5757814
10:  4    a -0.3053884
11:  4    a  1.5117812
12:  4    a  0.3898432

1.9.2

> library("data.table", lib.loc="C:/Program Files/R/R-3.0.2/library")
data.table 1.9.2  For help type: help("data.table")
> set.seed(1)
> dt <- data.table(id=rep(1:4, each=3),
+                  var1 = rep(letters[1:3], 4),
+                  var2 = rnorm(12),
+                  key="id,var1")
Error in forder(x, cols, sort = TRUE, retGrp = FALSE) :
  object 'Cforder' not found
> dt
    id var1       var2
 1:  1    a -0.6264538
 2:  1    b  0.1836433
 3:  1    c -0.8356286
 4:  2    a  1.5952808
 5:  2    b  0.3295078
 6:  2    c -0.8204684
 7:  3    a  0.4874291
 8:  3    b  0.7383247
 9:  3    c  0.5757814
10:  4    a -0.3053884
11:  4    b  1.5117812
12:  4    c  0.3898432
>
> key(dt)
[1] "id"   "var1"
> dt[.(unique(id)), list(var1, var2)]
Error in `[.data.table`(dt, .(unique(id)), list(var1, var2)) :
  object 'Cbmerge' not found

It seems that in the 1.9.0 version when you join using fewer keys than the
whole set of keys, the first values of the remaining keys are "carried
forward". Other column looks fine.

In the 1.9.2 instead some dependencies seem missing.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/datatable-help/attachments/20140227/97f3390b/attachment.html>


More information about the datatable-help mailing list