Function to let last non NA value of a variable be carried forward
Value
a variable similar to the input but with non-leading NAs replaced by last non-NA value. Leading non-NAs will either be removed or remain as NAs.
Examples
x <- c(NA, NA, NA, NA, 1, 3, 52, 5, 6, NA, 532, NA, NA, NA, 43)
y <- carryforward(x)
z <- carryforward(x, na.rm = FALSE)
