mutate_f | R Documentation |
A function to create new variable(s) based on existing ones.
mutate_f(.data, ...)
## S3 method for class 'data.table'
mutate_f(.data, ...)
## S3 method for class 'tbl'
mutate_f(.data, ...)
## S3 method for class 'grouped_df'
mutate_f(.data, ...)
## S3 method for class 'data.frame'
mutate_f(.data, ...)
.data |
A data.frame, data.table, or tbl |
... |
Name-value pairs of expressions, following data.table syntax: "new_col" := expression. Multiple assignments can be done via c("new_col1", "new_col2") := expression_returning_a_list. If unnamed, names of each list elements will be used |
a data.frame, data.table, or a tbl
df <- data.frame(baz = 1:10, foo = c(rep(1, 5), rep(2, 5)))
df %>%
dplyr::group_by(foo) %>%
mutate_f(c('foo', 'bar') := list(a = cumsum(baz), b = baz*2))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.