Usage
make_analysis(
design,
survey,
choices,
col,
analysis,
none_label = NULL,
group = NULL,
level = 0.9,
na_rm = TRUE,
vartype = "ci",
get_label = TRUE
)
Arguments
- design
A design object
- survey
The survey sheet from Kobo that contains at least column 'list_name' (split from 'type') and 'name'
- choices
The choices sheet from Kobo contains at least column 'list_name' (split from 'type') and 'name'
- col
Column to make analysis from
- analysis
One of "median", "mean", "prop_simple", "prop_simple_overall", "prop_multiple", "prop_multiple_overall", "ratio"
- none_label
Label for recoding NA if "prop_simple_overall" is selected. If NULL, the code "none_prop_simple_overall" is used as a label.
- group
A grouping variable, quoted
- level
Confidence level to pass to
svy_*
functions- na_rm
Should NAs be removed prior to calculation ?
- vartype
Parameter from
srvyr
functions. Default to "ci"- get_label
Should label(s) be joined? Default to
TRUE
General information
Survey and choices must be the final recoded versions of the data. For instance if you have recoded some "other" answers to new choices in the dataset. It must have been added to the choices sheet of the Kobo tool.
Design is simply a design object mapped from the dataset thanks to
srvyr::as_survey_design()
.Variables colnames must follow the following pattern in order for
Types of analysis
Median: "median" computes the weighted median using
svy_median()
under the hoodMean : "mean" computes the weighted mean using
svy_mean()
under the hoodCount numeric : "count_numeric" considers a numeric variable as a character one and then computes a simple proportion out of it.
Simple proportion : there are two different possible calculation. The first one "prop_simple" removes NA values and calculate the weighted proportion thanks to
svy_prop()
. The second one "prop_simple_overall" mutate NA values to "none_prop_simple_overall" and then calculates the weighted proportion.Multiple proportion : there are two different possible calculation. The first one "prop_multiple" removes NA values from each dummy 1/0 choice column and calculate the weighted proportion thanks to
svy_prop()
. The second one "prop_multiple_overall" mutate NA values to 0 for each dummy 1/0 choice column and then calculates the weighted proportion.Ratio: ratio is still under construction for managing NAs. For now it removes them and simply computes the ratio of numeric columns col1 over col2, when
col
is "col1,col2".