View source: R/first_present.R
first_present | R Documentation |
Returns the first or last non-NA value of x
when sorted by order_by
.
first_present(x, order_by = NULL, default = NA)
last_present(x, order_by = NULL, default = NA)
x |
A vector |
order_by |
Another vector to sort |
default |
A default value to use if the position does not exist in the input. |
The first or last non-NA value in x
.
If there are no non-NA values, NA is returned.
first_present(x = c(NA, 1, 2, NA), order_by = c(4, 3, 2, 1))
last_present(x = c(NA, 1, 2, NA), order_by = c(4, 3, 2, 1))
first_present(x = c(NA, 1, 2, NA), order_by = c(1, 2, 3, 4))
last_present(x = c(NA, 1, 2, NA), order_by = c(1, 2, 3, 4))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.