I have a large dataset. Two of the columns contains YES and No Values. Column.A has 0 NA values while Column.B contains around 40% NA values and dataset holds 500 lines where Col.B is the opposite of Col.A
Sample Columns
Col.A Col.B
Yes No
Yes NA
No Yes
No yes
Yes No
No NA
I'm wanting to replace all the NA values in Col.B with what ever the opposite is of Col.A
I have been trying to replace all of Col.B based on Col.A Value using a for loop
for (j in 1:500)
{
if (Col.A == YES )
{
Col.B = "NO "
}
else
{
Col.B = "YES "
}
}
However the IF statement is coming back with 'YES' not found
Aucun commentaire:
Enregistrer un commentaire