srvyr (version 0.3.5)

unweighted: Calculate the an unweighted summary statistic from a survey

Description

Calculate unweighted summaries from a survey dataset, just as on a normal data.frame with summarise.

Usage

unweighted(x, .svy = current_svy(), ...)

Arguments

x

A variable or expression

.svy

A tbl_svy object. When called from inside a summarize function the default automatically sets the survey to the current survey.

...

Ignored

Examples

Run this code
# NOT RUN {
library(survey)
library(dplyr)
data(api)

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

dstrata %>%
  summarise(api99_unw = unweighted(mean(api99)),
            n = unweighted(n()))

dstrata %>%
  group_by(stype) %>%
  summarise(api_diff_unw = unweighted(mean(api00 - api99)))

# }

Run the code above in your browser using DataCamp Workspace