The following code works, but I canβt find the documentation for the ".." operator (period) in the help of data.table and vignette:
library(data.table) cols <- c("mpg", "gear") DT <- as.data.table(mtcars) DT[, ..cols]
Output:
mpg gear 1: 21.0 4 2: 21.0 4 3: 22.8 4 4: 21.4 3 5: 18.7 3 ...
Why does this work, is there any documentation for this?
PS: Normally, I would use mget , etc ...
Edit 1: This is not a simple R function of reserved names ... , ..1 , ..2 , etc., which are used to refer to arguments passed from the caller (see ?Reserved ). In my example, not a number is used, but characters after two points.
Edit 2: this is not a duplicate , as the Rich Scriven example shows:
> mtcars[, ..cols] Error in `[.data.frame`(mtcars, , ..cols) : object '..cols' not found
r data.table
R yoda
source share