I have a DF with behavioral data of an experiment (emotional stroop task) with trials which are either congruent or incrongruent. I would like to create a new variable in my DF called "Repetition", which will be coded as followed:
- "yes (or actually -0.5) if the trial n and the trial n-1 are both congruent or are both incongruent
- "No" (or actually 0.5) if the trial n and the trial n-1 are one congruent and one incongruent.
When I create a new variable, I usually use this (example):
DF <- DF %>%
mutate (CR = ifelse ((emotion =="FEA" & Reponse == 2) | (emotion == "NEU" & Reponse == "NaN"), -0.5, 0.5))
But I don't know how to use this kind of statement when I have to check conditions in two different line...
Any help would be highly appreciated!
Aucun commentaire:
Enregistrer un commentaire