Description Usage Arguments Details Value Examples
Replaces any values < 0 with NA, calculates the subgroup mean, then replaces missing values with the subgroup mean.
1 2 3 4 5 6 | impute_mean(
data,
var_names,
remove_zeros = FALSE,
strat_vars = c("year", "sex", "imd_quintile", "age_cat")
)
|
data |
Data table - the Health Survey for England data |
var_names |
Character vector - the variable names to be imputed |
remove_zeros |
Logical - should zeros be treated as missing data |
strat_vars |
Character vector - the variables by which to stratify the subgroup means |
If not all NAs can be imputed with the fine scale starting amount of stratification, imputation is attempted again, removing the stratification variable specified last.
Returns an updated version of data in which the variables specified have had their missing values imputed with the subgroup means.
1 2 3 4 5 6 7 8 9 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.