Compute and keep only new columns.

# S3 method for ExprBuilder
transmute(
  .data,
  ...,
  .enlist = TRUE,
  .sequential = FALSE,
  .parse = getOption("table.express.parse", FALSE),
  .chain = getOption("table.express.chain", TRUE)
)

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

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

Arguments

.data

An instance of ExprBuilder.

...

Clauses for transmuting columns. For j inside the data.table's frame.

.enlist

See details.

.sequential

If TRUE, each expression in ... is assigned to a nested body within curly braces to allow them to use variables created by previous expressions. The default is FALSE because enabling this may turn off some data.table optimizations.

.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

Everything in ... is wrapped in a call to list by default. If only one expression is given, you can set .enlist to FALSE to skip the call to list.

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

Examples


data("mtcars")

data.table::as.data.table(mtcars) %>%
    transmute(ans = mpg * 2)
#>      ans
#>  1: 42.0
#>  2: 42.0
#>  3: 45.6
#>  4: 42.8
#>  5: 37.4
#>  6: 36.2
#>  7: 28.6
#>  8: 48.8
#>  9: 45.6
#> 10: 38.4
#> 11: 35.6
#> 12: 32.8
#> 13: 34.6
#> 14: 30.4
#> 15: 20.8
#> 16: 20.8
#> 17: 29.4
#> 18: 64.8
#> 19: 60.8
#> 20: 67.8
#> 21: 43.0
#> 22: 31.0
#> 23: 30.4
#> 24: 26.6
#> 25: 38.4
#> 26: 54.6
#> 27: 52.0
#> 28: 60.8
#> 29: 31.6
#> 30: 39.4
#> 31: 30.0
#> 32: 42.8
#>      ans