View source: R/watanabe-df-manipulation.R
mapCols | R Documentation |
Maps fun
to each element of the the columns of df
specified in ...
. Returns the original data frame with the values of specified columns updated with the values produced from mapping the function
mapCols(df, fun, cols = c(), ...)
df |
A dataframe. |
fun |
A function to apply to each element of the selected columns. Elements of these columns will be the first argument passed to this function. |
cols |
A vector containing the names (as strings) or index numbers of the columns with elements to which to apply |
... |
Additional arguments to pass to fun |
A dataframe of the same dimensions as df
with cols
containing the results of applying fun
to each element.
mapCols
works by folding over the set of columns to manipulate. For each column in cols
, runs fun
over its elements using sapply and replacing the column's original contents with the output.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.