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, ...)
x | A tibble |
---|---|
col | Column to pass as a vector to |
f | Function to be mapped to |
... | Additional arguments to |
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
.