Dear Data Table Help List,
I am using data.table version 1.6 (with R version 2.13.0, 64-bit on Windows 7)
and I've come across some strange behavior.
Please look at the following example, where I simply take the mean of two
numbers.
> table1 <- data.table(A=c("a","b","b"),B=c(4,5,NA))
> setkey(table1,A)
> table1["b",mean(B,na.rm=T)]
A V1
[1,] b 5
# EXPECTED OUTPUT
> table2 <- data.table(A=c("a","b","b"),B=c(4,5,NA))
> table2[A=="b",mean(B,na.rm=TRUE)]
[1] 5
# LESS EFFICIENT, BUT EXPECTED OUTPUT
> table2[A=="b",mean(B,na.rm=T)]
Error in `[.data.table`(x, irows, all.vars(jsub), with = FALSE) :
undefined columns selected
# WHY THE ERROR?
Any help would be much appreciated.
Regards,
Alex
_______________________________________________
datatable-help mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help