Returns first non-NA
value from a set of vectors.
Source: R/janitor_deprecated.R
use_first_valid_of.Rd
Warning: Deprecated, do not use in new code. Use dplyr::coalesce()
instead.
At each position of the input vectors, iterates through in order and returns the first non-NA value.
This is a robust replacement of the common ifelse(!is.na(x), x, ifelse(!is.na(y), y, z))
.
It's more readable and handles problems like ifelse()
's inability to work with dates in this way.