ARD Dichotomous Survey Statistics
Source:R/ard_dichotomous.survey.design.R
ard_dichotomous.survey.design.Rd
Compute Analysis Results Data (ARD) for dichotomous summary statistics.
Usage
# S3 method for class 'survey.design'
ard_dichotomous(
data,
variables,
by = NULL,
value = cards::maximum_variable_value(data$variables[variables]),
statistic = everything() ~ c("n", "N", "p", "p.std.error", "deff", "n_unweighted",
"N_unweighted", "p_unweighted"),
denominator = c("column", "row", "cell"),
fmt_fn = NULL,
stat_label = everything() ~ list(p = "%", p.std.error = "SE(%)", deff =
"Design Effect", n_unweighted = "Unweighted n", N_unweighted = "Unweighted N",
p_unweighted = "Unweighted %"),
...
)
Arguments
- data
(
survey.design
)
a design object often created withsurvey::svydesign()
.- variables
(
tidy-select
)
columns to include in summaries.- by
(
tidy-select
)
results are calculated for all combinations of the column specified and the variables. A single column may be specified.- value
(named
list
)
named list of dichotomous values to tabulate. Default iscards::maximum_variable_value(data$variables)
, which returns the largest/last value after a sort.- statistic
(
formula-list-selector
)
a named list, a list of formulas, or a single formula where the list element is a character vector of statistic names to include. See default value for options.- denominator
(
string
)
a string indicating the type proportions to calculate. Must be one of"column"
(the default),"row"
, and"cell"
.- fmt_fn
(
formula-list-selector
)
a named list, a list of formulas, or a single formula where the list element is a named list of functions (or the RHS of a formula), e.g.list(mpg = list(mean = \(x) round(x, digits = 2) |> as.character))
.- stat_label
(
formula-list-selector
)
a named list, a list of formulas, or a single formula where the list element is either a named list or a list of formulas defining the statistic labels, e.g.everything() ~ list(mean = "Mean", sd = "SD")
oreverything() ~ list(mean ~ "Mean", sd ~ "SD")
.- ...
These dots are for future extensions and must be empty.
Examples
survey::svydesign(ids = ~1, data = mtcars, weights = ~1) |>
ard_dichotomous(by = vs, variables = c(cyl, am), value = list(cyl = 4))
#> {cards} data frame: 32 x 11
#> group1 group1_level variable variable_level stat_name stat_label stat
#> 1 vs 0 cyl 4 n n 1
#> 2 vs 0 cyl 4 N N 18
#> 3 vs 0 cyl 4 p % 0.056
#> 4 vs 0 cyl 4 p.std.error SE(%) 0.055
#> 5 vs 0 cyl 4 deff Design E… Inf
#> 6 vs 0 cyl 4 n_unweighted Unweight… 1
#> 7 vs 0 cyl 4 N_unweighted Unweight… 18
#> 8 vs 0 cyl 4 p_unweighted Unweight… 0.056
#> 9 vs 1 cyl 4 n n 10
#> 10 vs 1 cyl 4 N N 14
#> ℹ 22 more rows
#> ℹ Use `print(n = ...)` to see more rows
#> ℹ 4 more variables: context, fmt_fn, warning, error