R/ard_categorical.survey.design.R
ard_categorical.survey.design.Rd
Compute tabulations on survey-weighted data.
The counts and proportion ("N"
, "n"
, "p"
) are calculated using survey::svytable()
,
and the standard errors and design effect ("p.std.error"
, "deff"
) are
calculated using survey::svymean()
.
The unweighted statistics are calculated with cards::ard_categorical.data.frame()
.
# S3 method for class 'survey.design'
ard_categorical(
data,
variables,
by = NULL,
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 %"),
...
)
(survey.design
)
a design object often created with survey::svydesign()
.
(tidy-select
)
columns to include in summaries.
(tidy-select
)
results are calculated for all combinations of the column specified
and the variables. A single column may be specified.
(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.
(string
)
a string indicating the type proportions to calculate. Must be one of
"column"
(the default), "row"
, and "cell"
.
(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()))
.
(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")
or
everything() ~ list(mean ~ "Mean", sd ~ "SD")
.
These dots are for future extensions and must be empty.
an ARD data frame of class 'card'
svy_titanic <- survey::svydesign(~1, data = as.data.frame(Titanic), weights = ~Freq)
ard_categorical(svy_titanic, variables = c(Class, Age), by = Survived)
#> {cards} data frame: 96 x 11
#> group1 group1_level variable variable_level stat_name stat_label stat
#> 1 Survived No Class 1st n n 122
#> 2 Survived No Class 1st N N 1490
#> 3 Survived No Class 1st p % 0.082
#> 4 Survived No Class 1st p.std.error SE(%) 0.086
#> 5 Survived No Class 1st deff Design E… 0.896
#> 6 Survived No Class 2nd n n 167
#> 7 Survived No Class 2nd N N 1490
#> 8 Survived No Class 2nd p % 0.112
#> 9 Survived No Class 2nd p.std.error SE(%) 0.111
#> 10 Survived No Class 2nd deff Design E… 1.128
#> ℹ 86 more rows
#> ℹ Use `print(n = ...)` to see more rows
#> ℹ 4 more variables: context, fmt_fn, warning, error