srvyr (version 0.3.1)

cascade: 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

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

Arguments

.data,

tbl A tbl_svy object

...

Name-value pairs of summary functions

.dots

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

.fill

Value to fill in for group summaries

Examples

Run this code
# NOT RUN {
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))

# }

Run the code above in your browser using DataCamp Workspace