Summarise multiple values into cascading groups

Description

cascade is similar to summarise, but calculates a summary statistics for the total of a group in addition to each group.

Usage

1
2
3
cascade(.data, ..., .fill = NA)

cascade_(.data, ..., .dots, .fill = NA)

Arguments

.data,

tbl A tbl_svy object

...

Name-value pairs of summary functions

.fill

Value to fill in for group summaries

.dots

Used to work around non-standard evaluation. See vignette("nse", package = "dplyr") for details.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
library(survey)
data(api)

dstrata <- apistrat %>%
  as_survey_design(strata = stype, weights = pw)

dstrata_grp <- dstrata %>%
  group_by(stype)

dstrata_grp %>%
  cascade(api99 = survey_mean(api99),
            api00 = survey_mean(api00),
            api_diff = survey_mean(api00 - api99))