Select columns of a data.table::data.table.

# S3 method for ExprBuilder
select(
  .data,
  ...,
  .negate = FALSE,
  .parse = getOption("table.express.parse", FALSE),
  .chain = getOption("table.express.chain", TRUE)
)

# S3 method for EagerExprBuilder
select(.data, ..., .parent_env = rlang::caller_env())

# S3 method for data.table
select(.data, ...)

Arguments

.data

An instance of ExprBuilder.

...

Clause for selecting columns. For j inside the data.table's frame.

.negate

Whether to negate the selection semantics and keep only columns that do not match what's given in ....

.parse

Logical. Whether to apply rlang::parse_expr() to obtain the expressions.

.chain

Logical. Should a new frame be automatically chained to the expression if the clause being set already exists?

.parent_env

See end_expr()

Details

The expressions in ... support tidyselect::select_helpers.

To see more examples, check the vignette, or the table.express-package entry.

Examples


data("mtcars")

data.table::as.data.table(mtcars) %>%
    select(mpg:cyl)
#>      mpg cyl
#>  1: 21.0   6
#>  2: 21.0   6
#>  3: 22.8   4
#>  4: 21.4   6
#>  5: 18.7   8
#>  6: 18.1   6
#>  7: 14.3   8
#>  8: 24.4   4
#>  9: 22.8   4
#> 10: 19.2   6
#> 11: 17.8   6
#> 12: 16.4   8
#> 13: 17.3   8
#> 14: 15.2   8
#> 15: 10.4   8
#> 16: 10.4   8
#> 17: 14.7   8
#> 18: 32.4   4
#> 19: 30.4   4
#> 20: 33.9   4
#> 21: 21.5   4
#> 22: 15.5   8
#> 23: 15.2   8
#> 24: 13.3   8
#> 25: 19.2   8
#> 26: 27.3   4
#> 27: 26.0   4
#> 28: 30.4   4
#> 29: 15.8   8
#> 30: 19.7   6
#> 31: 15.0   8
#> 32: 21.4   4
#>      mpg cyl