Take the first value that isn't missing. Adapted from http://stackoverflow.com/a/40515261/1082435.
first_nonmissing(x, value_if_all_na = NULL, na_codes = NULL)
A vector of values to collapse.
A scalar value to return if all elements are missing
(i.e., they are all either NA
, or one of the na_codes
).
A vector of codes that represent missing values.
A scalar of converted names.
value_if_all_na
and na_codes
must have the same data type as x
.
If value_if_all_na
is null, then an NA
will be returned.
If na_codes
is null, then all non-NA values are considered.