This (vectorized) function returns the first
non-NA
argument, similar to the SQL function
COALESCE
. If a vector or matrix is passed as first argument,
the remaining arguments are recycled to generate a vector/matrix of
the same dimension, and coalescing is done element by element.
coalesce.na(x, ...)
x | The first value to coalesce. |
---|---|
... | Other values to coalesce. |
A vector of the same length as x
.
Other deprecated functions: df_to_list-deprecated
,
hms.to.seconds-deprecated
,
kimisc-deprecated
,
list_to_df-deprecated
,
nc-deprecated
,
nlist-deprecated
,
ofactor-deprecated
,
sample.rows-deprecated
,
seconds.to.hms-deprecated
,
thisfile-deprecated
,
tll-deprecated
,
vswitch-deprecated
coalesce.na(NA, -1)#>#> [1] -1coalesce.na(5, 3)#> [1] 5coalesce.na(c(1,NA,NA), c(NA,2))#> Warning: object length is not a multiple of first object length#> [1] 1 2 NAcoalesce.na(matrix(c(NA, 1:3), nrow=2))#> [,1] [,2] #> [1,] NA 2 #> [2,] 1 3coalesce.na(NA)#> [1] NA