Skip to Content

Combining Survey Items in R/ Recoding NAs

I have two lists (from a multi-wave survey) that look like this:

X1 X2
1  NA
NA  2
NA  NA

How can I easily combine this into a third item, where the third column always takes the non-NA value of column X1 or X2, and codes NA when both values are NA?