Skip to contents

Survey analysis

Usage

svy_analysis(
  design,
  analysis,
  vars,
  group = NULL,
  group_key_sep = " -/- ",
  na_rm = TRUE,
  vartype = "ci",
  level = 0.95,
  ratio_key_sep = " -/- ",
  interact_key_sep = " -/- ",
  quantiles = c(0.25, 0.5, 0.75),
  ak = TRUE,
  ak_overall_sep = " @/@ ",
  ak_main_sep = " -/-",
  ak_var_to_value_sep = " %/% ",
  ...
)

Arguments

design

A srvyr::design object.

analysis

Analysis type. See details for more, well, details.

vars

A variable to calculate from.

group

A quoted vector of columns to group by. Default to NULL for no group.

group_key_sep

A character string to separate grouping column names in a fancy 'group_key' column.

na_rm

Should NAs from var be removed? Default to TRUE.

vartype

Report variability as one or more of: standard error ("se", default), confidence interval ("ci"), variance ("var") or coefficient of variation ("cv").

level

A single number or vector of numbers indicating the confidence level

ratio_key_sep

A separator for the ratio key.

interact_key_sep

A character string to separate interactions columns in a fancy 'interact_key" column.

quantiles

A vector of quantiles to calculate

ak

Boolean. Add the analysis key?

ak_overall_sep

The overall separator between items, e.g. between the type of analysis and the variables information.

ak_main_sep

The main separator between variables, e.g. between the two grouping columns.

ak_var_to_value_sep

The separator between the variable and its value.

...

Other parameters to pass to the used srvyr method.

Value

A survey-summarized-median data frame

Specificity per type of analysis

The possible analysis type are: mean for svy_mean(), median for svy_median(), interact for svy_interact(), proportion for svy_proportion(), ratio for svy_ratio(), or quantile svy_quantile().

  • If analysis is "ratio": vars takes a named vector. Names will be passed to nums in svy_ratio() and values to denoms.

  • If analysis is "interact": vars is the equivalent of interact.

See also

Other survey analysis functions: auto_svy_analysis(), svy_interact(), svy_mean(), svy_median(), svy_proportion(), svy_quantile(), svy_ratio()