naReplace {ahw} | R Documentation |
Replaces NA-values in vec
with last non-NA value
Description
Assumes first element is non-NA
Usage
naReplace(vec)
Arguments
vec |
Vector of any type |
Value
numeric
vector
with each NA
entry replaced with the last previous non-NA
entry.
Note
Can be replaced by link[zoo]{na.locf0}
Author(s)
Pål Christie Ryalen <p.c.ryalen@medisin.uio.no>
Examples
naReplace(c(1, 2, 3, NA, NA, 4))
naReplace(c("text", NA, NA))
[Package ahw version 0.1.0 Index]