A convenience function to return the last value which is not NA in a vector
Usage
lastNotNa(x, default = "Unknown")
Arguments
- x
a vector to look for the last value in
- default
a default value to use when all values are NA in a vector
Value
a single element from the last non NA value in x (or the default)
Examples
lastNotNa(c(1:4,NA,NA))
#> [1] 4
lastNotNa(c(letters[1:4],NA,'z',NA))
#> [1] "z"
lastNotNa(c(NA,NA))
#> [1] "Unknown"