Add or update columns of a data.table::data.table, possibly by reference using
:=
.
# S3 method for ExprBuilder
mutate(
.data,
...,
.sequential = FALSE,
.unquote_names = TRUE,
.parse = getOption("table.express.parse", FALSE),
.chain = getOption("table.express.chain", TRUE)
)
# S3 method for EagerExprBuilder
mutate(.data, ..., .parent_env = rlang::caller_env())
# S3 method for data.table
mutate(.data, ...)
An instance of ExprBuilder.
Mutation clauses.
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.
Passed to rlang::enexprs()
. Set to FALSE
if you want to pass the single
:=
expression.
Logical. Whether to apply rlang::parse_expr()
to obtain the expressions.
Logical. Should a new frame be automatically chained to the expression if the clause being set already exists?
See end_expr()
To see more examples, check the vignette, or the table.express-package entry.
data("mtcars")
data.table::as.data.table(mtcars) %>%
start_expr %>%
mutate(mpg_squared = mpg ^ 2)
#> .DT_[, `:=`(mpg_squared = mpg^2)]