Hoping to create the new column D based on three existing columns: "A" "B" and "C". The dataset also have other variables E, F, G, etc.
Whenever A or B or C has a value, other two columns have NAs (E,F, G, not affected by them). The new variable "D" I need should import whatever the existing values from any of the A,B, or C columns.
A B C D E F G
1 NA NA 1
NA 2 NA 2
NA 4 NA 4
NA NA 2 2
NA NA 3 3
Any simple codes within any packages that can do the trick? Thank you in advance!
I have seen other codes that can do the work but their datasets only have A,B and C, but my data set has other existing columns, so I need codes that can specify the A, B and C columns.