Several SQL languages (I mostly use postgreSQL) have a function called coalesce which returns the first non null column element for each row. This can b
From data.table >= 1.12.3 you can use fcoalesce.
data.table >= 1.12.3
fcoalesce
library(data.table) fcoalesce(a, b, c) # [1] 1 2 NA 4 6
For more info, including a benchmark, see NEWS item #18 for development version 1.12.3.