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
Recode (or compute) from two variables
Re: Recode (or compute) from two variables
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
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
how about the following?