coalesce {preputils} | R Documentation |
select 1st existing value of several columns
Description
Inspired by the respectively named sql function. In a list of vectors with equal length the function for each of the observations selects the first value that is not NA, in the order provided
Usage
coalesce(...)
Arguments
... |
vectors holding the values, sepearated by "," (commonly columns of data.frame) |
Details
Data are transformed according to
b=\frac{2^M}{2^M+1}
Value
A named vector holding the supplemented values
Examples
a1 = c(1,NA,NA,NA)
a2 = c(2,2,NA,NA)
a3 = c(NA,3,3,NA)
cbind(a1,a2,a3,suppl=coalesce(a1,a2,a3))
[Package preputils version 1.0.3 Index]