I want to use as quote (or expression) as i
in a data.table. But it seems to be not possible.
Here is a minimal example:
library(data.table)
dt <- data.table(a = 1:10)
dt[a == 5,] # Everything well
dt[quote(a == 5),] # Error: i has not evaluated to logical, integer or double
dt[expression(a == 5),] # Error: i has not evaluated to logical, integer or double
The help page of data.table states for i
:
Integer, logical or character vector, single column numeric matrix, expression of column names, list, data.frame or data.table.
So I think, it should work with expressions. What is my mistake? Or is there a way to "unquote" the quote?