Learn R Programming

table.express (version 0.1.1)

mutate_sd: Mutate subset of data

Description

Like mutate-table.express but for a single call and some .SDcols.

Usage

mutate_sd(.data, .how = identity, ..., .SDcols,
  .parse = getOption("table.express.parse", FALSE),
  .chain = getOption("table.express.chain", TRUE))

Arguments

.data

An instance of ExprBuilder.

.how

The function or function call that will perform the transformation.

...

Possibly more arguments for .how.

.SDcols

See data.table::data.table and the details here.

.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?

Details

This function works similar to transmute_sd() but keeps all columns and can modify by reference, like mutate-table.express.

Additionally, .SDcols supports tidyselect::select_helpers, with the caveat 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.tables.

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

Examples

Run this code
# NOT RUN {
data("mtcars")

data.table::as.data.table(mtcars) %>%
    start_expr %>%
    mutate_sd(.COL * 2, .SDcols = c("mpg", "cyl"))

# }

Run the code above in your browser using DataLab