fill.na {eatTools} | R Documentation |
Missing values in a vector are replaced by the last (forward) or next (backward) observed value.
fill.na(vec, backwards = FALSE, na.rm = FALSE)
vec |
a vector |
backwards |
if |
na.rm |
if |
In the clinical literature, the procedure of replacing a missing value with the last observed value is known as the "Last Observation Carried Forward" imputation technique. However, there is a large body of literature suggesting that this method may lead to biased estimates of means and covariances and should therefore be avoided for imputation.
A vector with replaced missing values.
Martin Hecht
(vec <- c(NA, 1, NA, NA, 2, NA, 3, NA)) fill.na(vec) fill.na(vec, backwards = TRUE)