R - select the number that appears most in the line
I have df test
:
A B C
1 1 NA
2 NA NA
1 2 2
I want to create another column, say test$D
which is the number that appears the most on that row, except for NA. My desired df:
A B C D
1 1 NA 1
2 NA NA 2
1 2 2 2
I was looking for a similar type function rowMeans
with na.rm = T but couldn't find a suitable function for this situation. I really appreciate any help
+3
source to share
2 answers