The function will impute all NA values with either a given statistic (e.g. median) or with the largest group
Arguments
- 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
Details
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.
Examples
dfrm <- data.frame(num1 = c(NA,110))
impute_covar(dfrm$num1,type="median")
#> [1] 110 110
