knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(cuber)
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")

Then create the data cube, with the estimates of all the combinations of variables:

cube_df_(invented_wages, .vars = vars, fun_list = fun)


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