I have two variablesm MARKSV1201 and MARKSVA1201. MARKSVA1201 is only ever relevant if MARKSV1201 is missing, otherwise it will only mess up my analysis.
I try to write a script that sets MARKSVA1201 to '0' whenever a value for MARKSV1201 is recorded
if(!is.na(test$`MARKSV1201 `)){test$`MARKSVA1201 `=0}
This doesn't seem to work however, the program complains that the "condition is >1 and only the first element will be used"
I try using the ifelse-statement instead since I am working with vectors:
ifelse(!is.na(test$`MARKSV1201 `),test$`MARKSVASVA01 `==0,test$`MARKSVASVA01 `==test$`MARKSVASVA01 `)
This seems to work, but I'm only getting a logical vector.
How do I go about changing my actual values conditionally?
Aucun commentaire:
Enregistrer un commentaire