Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange column selection with logical condition #3013

Closed
alexnss opened this issue Aug 27, 2018 · 1 comment · Fixed by #3829
Closed

Strange column selection with logical condition #3013

alexnss opened this issue Aug 27, 2018 · 1 comment · Fixed by #3829
Labels
Milestone

Comments

@alexnss
Copy link

alexnss commented Aug 27, 2018

Reproducible example


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

@DavidArenburg
Copy link
Member

DavidArenburg commented Aug 27, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants