split_apply_df_ | R Documentation |
Apply a list of function calls to groups of a data frame
split_apply_df_(
.data,
.vars,
sep = ".",
fun_list = list(n = ~nrow(.data)),
...
)
.data |
a data frame. |
.vars |
character vector with the names of the columns for which the data frame will be divided. |
sep |
a character string to separate the terms. |
fun_list |
a named list of formulas with the desired function calls to
be evalutated on the data frame. The default value ( |
... |
additional optional arguments passed to |
a data frame with the function calls estimated for the groups defined by the combinations of variables.
data(invented_wages)
str(invented_wages)
# First create a list of function calls (with formulas)
fun <- list(m1 = ~weighted.mean(wage, sample_weights), s = ~sum(sample_weights))
# And then apply them to subsets of data defined by the combinations of variables
split_apply_df_(invented_wages, .vars = "gender", fun_list = fun)
split_apply_df_(invented_wages, .vars = c("gender", "sector"), fun_list = fun)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.