Fill down missing values with the latest non-missing value

filldown(x)

Arguments

x

A vector

Value

A vector or list with the NA's replaced by the last observed value.

Examples

a <- c(1:5, "Howdy", NA, NA, 2:3, NA) filldown(a)
#> [1] "1" "2" "3" "4" "5" "Howdy" "Howdy" "Howdy" "2" #> [10] "3" "3"
filldown(c(NA, NA, NA, 3:5))
#> [1] NA NA NA 3 4 5