Recode (or compute) from two variables

General help and assistance with jamovi. Bug reports can be made at our issues page: https://github.com/jamovi/jamovi/issues . (If you're unsure feel free to discuss it here)
Post Reply
prog_frog
Posts: 7
Joined: Mon Jan 11, 2021 6:26 pm

Recode (or compute) from two variables

Post 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
Marielle
Posts: 9
Joined: Thu Jul 13, 2023 10:07 pm

Re: Recode (or compute) from two variables

Post 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
User avatar
jonathon
Posts: 2821
Joined: Fri Jan 27, 2017 10:04 am

Re: Recode (or compute) from two variables

Post 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 37157 times
Post Reply