cube_: Create a data cube and store it in a list

View source: R/split_apply_.R

cube_R Documentation

Create a data cube and store it in a list

Description

Create a data cube and store it in a list

Usage

cube_(.data, .vars, sep = ".", fun_list = list(n = ~nrow(.data)), ...)

Arguments

.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 (list(n = ~nrow(.data))) returns the number of rows (observations) and stores it in a column named n.

...

additional optional arguments passed to res2df (estimator_name and value).

Value

a list whose elements are data frame containing the estimates for each combination of variables.

Examples

data(invented_wages)
str(invented_wages)

# First create a list of function calls (with formulas) and
# a vector with names of the desired variables
fun <- list(m1 = ~weighted.mean(wage, sample_weights), s = ~sum(sample_weights))
vars <- c("gender", "sector")

# And then create the data cube, with the estimates of all the combinations
# of variables
cube_(invented_wages, .vars = vars, fun_list = fun)
cube_(invented_wages, .vars = vars, fun_list = fun, 
      estimator_name = "statistica", value = "stima")


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