res2df: Put the results of 'split_apply_' in a data frame

View source: R/split_apply_.R

res2dfR Documentation

Put the results of 'split_apply_' in a data frame

Description

Put the results of 'split_apply_' in a data frame

Usage

res2df(.nested_list, sep = ".", estimator_name = "estimator", value = "value")

Arguments

.nested_list

a nested list, the output of split_apply_.

sep

a character string to separate the terms.

estimator_name

character string with the name to be given to the column with the type of the estimated statistics (default: "estimator").

value

character string with the name of the column that will contain the values of the estimated statistics (default: "value").

Value

a data frame

Examples

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
tmp <- split_apply_(invented_wages, .vars = c("gender", "sector"), fun_list = fun)
str(tmp)     # a list

res2df(tmp)  # a data frame


gibonet/cuber documentation built on Dec. 24, 2024, 5:17 p.m.