It's pretty common in R to use a logical vector for selecting, but this fails:
> x <- data.table(b = c(FALSE, TRUE), d = 1:2)
> x
b d
1: FALSE 1
2: TRUE 2
> x[b]
Error in eval(expr, envir, enclos) : object 'b' not found
> x[(b)]
b d
1: TRUE 2
This is a frequent mistake, see here and here
The problem can be avoided with more user friendly error message. For example:
Error in eval(expr, envir, enclos) : object 'b' not found
When 'i' is a single variable name, it is not considered an expression of column names and is instead evaluated in calling scope.
If 'b' is intended to be used as logical vector to index, wrap 'b' with () as expression.
It's pretty common in R to use a logical vector for selecting, but this fails:
This is a frequent mistake, see here and here
The problem can be avoided with more user friendly error message. For example: