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

comparing multiple columns including NAs in a dataframe R

$
0
0

I have a dataframe include 1,2 and bunch of NAs

I would like to compare these columns and save the results in a new column (let's say F) so that: if in each row all values are 1 then the new column get 1 for the same row if all values are 2, then assign 2 for the same row in new column if numbers are different (combination of 1 and 2) assign new number like 3 in the new

Do you have any idea how is it possible to doing so?


Viewing all articles
Browse latest Browse all 201839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>