Description Usage Arguments Value Examples
Finds the last value in a vector which is not NA
and
returns it. If all entries are NA
, it returns an NA
1 | last_non_NA(d)
|
d |
Vector with numeric entries and possibly |
Last value in d
with non-NA entry.
1 2 3 4 5 6 7 8 9 10 11 12 | last_non_NA(c(1, 2, 3, 4, NA))
values <- 1:100
values[sample(1:100, 10)] <- NA
df <- cbind(Year = c(rep(2000, 5), rep(2001, 5)),
as.data.frame(matrix(values, nrow = 10)))
library(dplyr)
df %>%
group_by(Year) %>%
summarize_each(funs(last_non_NA)) %>%
ungroup()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.