[datatable-help] Another CJ anomaly
Damian Betebenner
dbetebenner at nciea.org
Sun Dec 4 14:17:12 CET 2011
Not sure if this is corrected in the latest build on R-Forge but will report it anyway:
CJ doesn't do the cross product correctly:
require(data.table)
Y <- factor(1:2, levels=1:2, labels=c("MATHEMATICS", "READING"))
Z <- factor(1:3, levels=1:3, labels=paste(2008:2010, 2009:2011, sep="_"))
tmp.cj <- CJ(Y,Z)
> tmp.cj
V1 V2
[1,] MATHEMATICS 2008_2009
[2,] MATHEMATICS 2009_2010
[3,] MATHEMATICS 2010_2011
[4,] READING 2008_2009
[5,] READING 2009_2010
[6,] READING 2010_2011
### But subsetting tmp.cj shows weird behavior (the V2 levels disappear in some cases)
> tmp.cj[1:3]
V1 V2
[1,] MATHEMATICS 2008_2009
[2,] MATHEMATICS 2009_2010
[3,] MATHEMATICS 2010_2011
> tmp.cj[4:6]
V1 V2
[1,] READING <NA>
[2,] READING <NA>
[3,] READING <NA>
Any insight on the above greatly appreciated
Damian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/datatable-help/attachments/20111204/b3520be5/attachment.htm>
More information about the datatable-help
mailing list