Page 1 of 1

Recode (or compute) from two variables

Posted: Sat Feb 22, 2025 7:15 pm
by prog_frog
Let's say I have two existing dichotomous (0 or 1) variables. I want to create a new variable that is coded 1 if either of the original variables are coded 1, and otherwise code this new variable as 0. How could one do this in jamovi? It seems that transform only works with one source variable, not 2 or more? And I'm not sure how to use Compute to do this directly. I can think of a workaround or two (such as compute a summed variable from the two original ones, then recode that), but I'm checking to see if I'm missing something. Thanks!

~Doug

Re: Recode (or compute) from two variables

Posted: Sun Feb 23, 2025 10:14 am
by Marielle
If you know for sure that both variables contain only zeros and ones, then an easy way to compute a XOR is to check for inequality.

In compute: A != B

That will give the following results:
A = 0, B = 0 ==> FALSE
A = 0, B = 1 ==> TRUE
A = 1, B = 0 ==> TRUE
A = 1, B = 1 ==> FALSE

Then wrap that in an IF() if you want output values other than TRUE/FALSE

Re: Recode (or compute) from two variables

Posted: Sun Feb 23, 2025 11:02 pm
by jonathon
how about the following?
Screenshot 2025-02-24 at 10.02.11.png
Screenshot 2025-02-24 at 10.02.11.png (139.75 KiB) Viewed 50373 times