Learn R Programming

srvyr (version 0.1.1)

summarise: Summarise multiple values to a single value.

Description

Summarise multiple values to a single value.

Usage

summarise(.data, ...)
summarize(.data, ...)
summarise_(.data, ..., .dots)
summarize_(.data, ..., .dots)

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.

Details

Summarise for tbl_svy objects accepts several specialized functions. Each of the functions a variable (or two, in the case of survey_ratio), from the data.frame and default to providing the measure and its standard error.

The argument vartype can choose one or more measures of uncertainty, se for standard error, ci for confidence interval, var for variance, and cv for coefficient of variation. level specifies the level for the confidence interval.

The other arguments correspond to the analagous function arguments from the survey package.

The available functions are:

[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

Examples

Run this code
library(survey)
data(api)

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

dstrata %>%
  summarise(api99 = survey_mean(api99),
            api00 = survey_mean(api00),
            api_diff = survey_mean(api00 - api99))

dstrata_grp <- dstrata %>%
  group_by(stype)

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

Run the code above in your browser using DataLab