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.

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.