summarise_f: Reduce multiple values by summarisation functions.

summarise_fR Documentation

Reduce multiple values by summarisation functions.

Description

Create variables summarising exisiting variables, by using summarisation function.

Usage

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, ...)

Arguments

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

Value

a data.frame, data.table, or a tbl

Examples

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))

oucru-biostats/C306 documentation built on Sept. 1, 2024, 10:04 a.m.