summarise_f | R Documentation |
Create variables summarising exisiting variables, by using summarisation function.
summarise_f(.data, ...)
## S3 method for class 'data.frame'
summarise_f(.data, ...)
## S3 method for class 'data.table'
summarise_f(.data, ...)
## S3 method for class 'tbl'
summarise_f(.data, ...)
## S3 method for class 'grouped_df'
summarise_f(.data, ...)
.data |
A data.frame, data.table, or tbl |
... |
Summarisation functions. Each of which must return a named list, whose names stand for new variables' names. Anonymous functions must be wrapped in parentheses. |
a data.frame, data.table, or a tbl
df <- data.frame(baz = 1:10, foo = c(rep(1, 5), rep(2, 5)), bar =4:13)
df %>%
dplyr::group_by(foo) %>%
summarise_f((function(baz) list(a = cumsum(baz), b = baz*2))(baz), rangemisc::overlap_collapse(bar, baz))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.