impute_df {zlog} | R Documentation |
Imputation
Description
Impute NA
values with the logmean, mean, minimal or maximum reference value.
Usage
impute_df(x, limits, method = c("logmean", "mean", "min", "max"))
Arguments
x |
|
limits |
|
method |
|
Value
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
.
Note
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
.
Author(s)
Sebastian Gibb
Examples
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)