I have been trying to make a new column in data set, lets say jk. I want in this column the values from column a6 if value in column a6b is NA, otherwise I need the value from column a6b. I have written the following line of code for this operation:
Combined_Data %>% mutate(jk=if_else(a6b!= NA , a6b, a6))
But instead if intended result, this code is converting all values in jk column to NAs.
What I have:
df
a6 a6b
1 45 NA
2 62 32
3 NA 55
4 92 200
What I want:
df
a6 a6b jk
1 45 NA 45
2 62 32 32
3 NA 55 55
4 92 200 200
What I'm getting:
df
a6 a6b jk
1 45 NA NA
2 62 32 NA
3 NA 55 NA
4 92 200 NA