Compute Analysis Results Data (ARD) for statistics related to data missingness for survey objects
Usage
# S3 method for survey.design
ard_missing(
data,
variables,
by = NULL,
statistic = everything() ~ c("N_obs", "N_miss", "N_nonmiss", "p_miss", "p_nonmiss",
"N_obs_unweighted", "N_miss_unweighted", "N_nonmiss_unweighted", "p_miss_unweighted",
"p_nonmiss_unweighted"),
fmt_fn = NULL,
stat_label = everything() ~ list(N_obs = "Total N", N_miss = "N Missing", N_nonmiss =
"N not Missing", p_miss = "% Missing", p_nonmiss = "% not Missing",
N_obs_unweighted = "Total N (unweighted)", N_miss_unweighted =
"N Missing (unweighted)", N_nonmiss_unweighted = "N not Missing (unweighted)",
p_miss_unweighted = "% Missing (unweighted)", p_nonmiss_unweighted =
"% not Missing (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.- 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.- 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
svy_titanic <- survey::svydesign(~1, data = as.data.frame(Titanic), weights = ~Freq)
ard_missing(svy_titanic, variables = c(Class, Age), by = Survived)
#> {cards} data frame: 40 x 10
#> group1 group1_level variable stat_name stat_label stat
#> 1 Survived No Class N_nonmiss N not Mi… 1490
#> 2 Survived No Class N_obs Total N 1490
#> 3 Survived No Class p_nonmiss % not Mi… 1
#> 4 Survived No Class N_miss N Missing 0
#> 5 Survived No Class p_miss % Missing 0
#> 6 Survived No Class N_miss_unweighted N Missin… 0
#> 7 Survived No Class N_obs_unweighted Total N … 16
#> 8 Survived No Class p_miss_unweighted % Missin… 0
#> 9 Survived No Class N_nonmiss_unweighted N not Mi… 16
#> 10 Survived No Class p_nonmiss_unweighted % not Mi… 1
#> ℹ 30 more rows
#> ℹ Use `print(n = ...)` to see more rows
#> ℹ 4 more variables: context, fmt_fn, warning, error