impute_df | R Documentation |
Impute NA
values with the logmean, mean, minimal or maximum reference value.
impute_df(x, limits, method = c("logmean", "mean", "min", "max"))
x |
|
limits |
|
method |
|
data.frame
, the same as x
but missing values are replaced by
the corresponding logmean, mean, minimal or maximal reference values
depending on the chosen method
.
Imputation should be done prior to z()
/zlog()
transformation.
Afterwards the NA
could replaced by zero (for mean-imputation) via
d[is.na(d)] <- 0
.
Sebastian Gibb
l <- data.frame( param = c("alb", "bili"), age = c(0, 0), sex = c("both", "both"), units = c("mg/l", "µmol/l"), lower = c(35, 2), upper = c(52, 21) ) x <- data.frame( age = 40:48, sex = rep(c("female", "male"), c(5, 4)), # from Hoffmann et al. 2017 alb = c(42, NA, 38, NA, 50, 42, 27, 31, 24), bili = c(11, 9, NA, NA, 22, 42, NA, 200, 20) ) impute_df(x, l) impute_df(x, l, method = "min") zlog_df(impute_df(x, l), l)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.