Skip to contents

Set up survey data

Functions for specifying a survey’s structure

as_survey()
Create a tbl_svy from a data.frame
as_survey_design()
Create a tbl_svy survey object using sampling design
as_survey_rep()
Create a tbl_svy survey object using replicate weights
as_survey_twophase()
Create a tbl_svy survey object using two phase design

Calculate summary statistics of survey data

Functions for calculating summary measures taking into account complex survey design

cascade()
Summarise multiple values into cascading groups
group_by group_by_
Group a (survey) dataset by one or more variables.
interact()
Create interaction terms to group by when summarizing
summarise summarize
Summarise multiple values to a single value.
summarise_all summarize_all summarise_if summarize_if summarise_at summarize_at mutate_all mutate_if mutate_at filter_all filter_at filter_if select_all select_at select_if rename_all rename_at rename_if group_by_all group_by_at group_by_if mutate_each summarise_each summarize_each funs vars all_vars any_vars
Manipulate multiple columns.
survey_mean() survey_prop()
Calculate mean/proportion and its variation using survey methods
survey_total()
Calculate the total and its variation using survey methods
survey_quantile() survey_median()
Calculate the quantile and its variation using survey methods
survey_ratio()
Calculate the ratio and its variation using survey methods
survey_tally() survey_count()
Count/tally survey weighted observations by group
survey_var() survey_sd()
Calculate the population variance and its variation using survey methods
survey_corr()
Calculate correlation and its variation using survey methods
unweighted()
Calculate the an unweighted summary statistic from a survey
svychisq
Chisquared tests of association for survey data.
cur_svy_wts()
Get the full-sample weights for the current context
survey_old_quantile() survey_old_median()
Calculate the quantile and its variation using survey methods

Other supported dplyr functions

Other functions from dplyr that work on srvyr’s survey objects

as_tibble
Coerce survey variables to a data frame (tibble)
group_trim dplyr_single mutate transmute select pull rename rename_with filter drop_na
Single table verbs from dplyr and tidyr
groups ungroup group_vars group_data group_keys group_rows group_indices group_size n_groups
Get/set the grouping variables for tbl.
tbl_vars
List variables produced by a tbl.
group_map_dfr() group_map(<tbl_svy>)
Apply a function to each group
dplyr_filter_joins semi_join anti_join
Filtering joins from dplyr
collect compute
Force computation of a database query

(Primarily for package authors) Extend srvyr

Functions useful for package authors to extend srvyr

cur_svy() cur_svy_full() current_svy()
Get the survey data for the current context
get_var_est()
Get the variance estimates for a survey estimate
set_survey_vars()
Set the variables for the current survey variable
uninteract() is.interaction()
Break interaction vectors back into component columns
srvyr_interaction
srvyr interaction column

Other

Other things that don’t fit well in existing categories

as_survey_() as_survey_design_() as_survey_rep_() as_survey_twophase_() cascade_()
Deprecated SE versions of main srvyr verbs
srvyr-package srvyr
srvyr: A package for 'dplyr'-Like Syntax for Summary Statistics of Survey Data.
tbl_svy
tbl_svy object.