I am having trouble finding a solution to this: I want to replace those NA values with some text depending on the name of the variable. Ideally it would do something like:
if variable name is var2 or var3 or var4 replace in the same row with "text"
variable question
1 var1 <NA>
2 var2 <NA>
3 var3 <NA>
4 var4 <NA>
The closest I thought would work was:
df$question[df$variable = var2 OR var3 OR var4] <- text
it shouldn't be hard, i am just to blind to find the right answers :(.
(df$variable == "var2"| df$variable == "var3" | df$variable == "var4"). Note the use of|(elementwise comparison)