| impute_covar | R Documentation |
The function will impute all NA values with either a given statistic (e.g. median) or with the largest group
impute_covar(var, uniques = NULL, type = "median", verbose = FALSE)
var |
vector with the items that should be imputed |
uniques |
vector that defines unique records to enable calculation of stats on non duplicate values |
type |
character of length one defining the type of statistics to perform for imputation (see details) |
verbose |
logical indicating if additional information should be given |
The function can be used to impute continuous or categorical covariates. In case continuous covariates the type argument should be a statistic like median or mean. In case a categorical covariate is used, the type should be set to 'largest' in which case the category that occurs most is used. In case multiple values occur most, the last encountered is used.
a vector where missing values are imputed
Richard Hooijmaijers
dfrm <- data.frame(num1 = c(NA,110))
impute_covar(dfrm$num1,type="median")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.