dt1 <- data.table(A = letters[1:10], X = 1:10, key = "A")
dt2<-dt1[,rep(TRUE,2), with=F]
str(dt2)
Classes ‘data.table’ and 'data.frame': 10 obs. of 2 variables:
dt2<-dt1[,!(rep(FALSE,2)), with=F]
str(dt2)
Classes ‘data.table’ and 'data.frame': 0 obs. of 0 variables
attr(*, ".internal.selfref")=<externalptr>
vec<-c(FALSE,TRUE)
dt2<-dt1[,!vec, with=F]
str(dt2)
Classes ‘data.table’ and 'data.frame': 10 obs. of 1 variable:
dt2<-dt1[,(!(rep(FALSE,2))), with=F]
str(dt2)
Classes ‘data.table’ and 'data.frame': 10 obs. of 2 variables:
library(data.table)
data.table 1.11.5 IN DEVELOPMENT built 2018-08-23 18:52:44 UTC Latest news: r-datatable.com
R.version
_
platform x86_64-apple-darwin15.6.0
arch x86_64
os darwin15.6.0
system x86_64, darwin15.6.0
status
major 3
minor 5.1
The text was updated successfully, but these errors were encountered:
I have a feeling this is a duplicate of #2917. What basically happens is that rep(FALSE,2) is being evaluated separately from ! and and when data.table sees a vector full of FALSE it returns a null.data.table() before even reaching the ! part. I would say it's definitely a bug.
Reproducible example
library(data.table)
data.table 1.11.5 IN DEVELOPMENT built 2018-08-23 18:52:44 UTC Latest news: r-datatable.com
R.version
_
platform x86_64-apple-darwin15.6.0
arch x86_64
os darwin15.6.0
system x86_64, darwin15.6.0
status
major 3
minor 5.1
The text was updated successfully, but these errors were encountered: