Skip to content

creating variable that codes for the match/mismatch between two other variables

4 messages · Jonas Walter, PIKAL Petr

#
Hi
Well, why so complicated?

(mydat$Stimulus == mydat$Prediction)*1

gives you vector of 1 when there is match and 0 when there is no match. 

I do not understand your no prediction though. How is no prediction coded? If NA, the resulting vector will have NA in corresponding item too.

Regards
Petr
#
Hi Petr,

oh, that's really way more easier than the way I did it. Thanks for the hint!

The problem with "no prediction" is that these cases are already coded  
within the "Prediction" variable.

0 codes "no prediction required" while 1 and 2 codes for different  
predictions. Therefore, there are no NAs within this variable.

By applying the procedure suggested by you, I would receive 0-coding  
for both trials with wrong predictions and trials without any  
predictions.

But probably I can change coding within the Prediction-variable prior  
to applying your procedure.

Thanks again!

Best,
Jonas





Zitat von PIKAL Petr <petr.pikal at precheza.cz>:
#
Hi
Change

mydat$Prediction[mydat$Prediction==0] <- NA

and after that you shall get 0 when wrong prediction and NA when no prediction required

Regards
Petr