map_groups: Map a function to a single column within tibble groups

Description Usage Arguments Value

View source: R/utils.R

Description

A convenience function for mapping a function – which accepts a vector as input and outputs an atomic value – to a single column of a dataframe. If the dataframe is grouped, the function will be applied within each group.

Usage

1
map_groups(x, col, f, ...)

Arguments

x

A tibble

col

Column to pass as a vector to f.

f

Function to be mapped to col.

...

Additional arguments to f.

Value

A dataframe with the original grouped columns (if x had originally been grouped) and a data column containing the output of the mapped function f.


Sage-Bionetworks/mhealthtools documentation built on Sept. 20, 2020, 1:42 p.m.