View source: R/VERBS-mutate_sd.R
mutate_sd | R Documentation |
Like mutate-table.express but possibly recycling calls.
mutate_sd(.data, .SDcols, .how = identity, ...)
## S3 method for class 'ExprBuilder'
mutate_sd(
.data,
.SDcols,
.how = identity,
...,
.pairwise = TRUE,
.prefix,
.suffix,
.parse = getOption("table.express.parse", FALSE),
.chain = getOption("table.express.chain", TRUE)
)
## S3 method for class 'EagerExprBuilder'
mutate_sd(.data, ..., .parent_env = rlang::caller_env())
## S3 method for class 'data.table'
mutate_sd(.data, ...)
.data |
An instance of ExprBuilder. |
.SDcols |
See data.table::data.table and the details here. |
.how |
The function(s) or function call(s) that will perform the transformation. If many,
a list should be used, either with |
... |
Possibly more arguments for all functions/calls in |
.pairwise |
If |
.prefix, .suffix |
Only relevant when |
.parse |
Logical. Whether to apply |
.chain |
Logical. Should a new frame be automatically chained to the expression if the clause being set already exists? |
.parent_env |
See |
This function works similar to transmute_sd()
but keeps all columns and can modify by
reference, like mutate-table.express. It can serve like
dplyr's scoped mutation variants depending on what's given to .SDcols
.
Additionally, .SDcols
supports:
tidyselect::select_helpers
A predicate using the .COL
pronoun that should return a single logical when .COL
is
replaced by a column of the data.
A formula using .
or .x
instead of the aforementioned .COL
.
The caveat is that the expression is evaluated eagerly, i.e. with the currently captured
data.table
. Consider using chain()
to explicitly capture intermediate results as actual
data.table
s.
To see more examples, check the vignette, or the table.express-package entry.
data("mtcars")
data.table::as.data.table(mtcars) %>%
start_expr %>%
mutate_sd(c("mpg", "cyl"), ~ .x * 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.