# Example data frame
my_data <- dummy_data(1000)
# Summarise data
all_nested <- my_data |>
summarise_plus(class = c(year, sex),
values = c(weight, income),
statistics = c("sum", "pct_group", "pct_total", "sum_wgt", "freq"),
weight = weight,
nesting = "deepest",
na.rm = TRUE)
# Rename variables by repacing patterns
new_names <- all_nested |>
rename_pattern("pct", "percent") |>
rename_pattern("_sum", "")
Run the code above in your browser using DataLab