Fill down missing values with the latest non-missing value
filldown(x)
x | A vector |
---|
A vector or list with the NA's replaced by the last observed value.
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