Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

Is there a way to combine information from two columns into a single column in R?

$
0
0

I am working with a data set that has two columns, one of which will have useful information. The one without information will have NA as its value. I would like this information to go into a third column together. An example of the data would be as below

 1 NA NA
 2 NC NA
 3 NA Alabama

What would be a method to have the third column produce:

  1 NA
  2 NC
  3 Alabama

I tried paste(), but this yields the data below: The NAs in this case also become characters that say "NA".

 1 NA NA
 2 NC NA
 3 NA Alabama

Any ideas as to how to achieve the 2nd table as opposed to the third, with the NA values retaining their NA status instead of being a character string?


Viewing all articles
Browse latest Browse all 201839

Trending Articles