This block allows to add new variables and preserve existing ones using R expressions
(see dplyr::mutate()). Changes are applied after clicking the submit button.
Arguments
- exprs
Reactive expression returning character vector of expressions
- by
Character vector of column names for grouping. Default is empty.
- ...
Additional arguments forwarded to
blockr.core::new_block()
Examples
# Create a mutate expression block
new_mutate_expr_block(exprs = list(mpg_squared = "mpg^2"))
#> <mutate_expr_block<transform_block<block>>>
#> Name: "Mutate expr"
#> Data inputs: "data"
#> Initial block state:
#> $ exprs:List of 1
#> ..$ mpg_squared: chr "mpg^2"
#> $ by : chr(0)
#> Constructor: blockr.dplyr::new_mutate_expr_block()
if (interactive()) {
# Basic usage with mtcars datase
library(blockr.core)
serve(new_mutate_expr_block(), data = list(data = mtcars))
# With a custom dataset
df <- data.frame(x = 1:5, check.names = FALSE)
df$`2025 Sales` <- letters[1:5]
serve(new_mutate_expr_block(), data = list(data = df))
}