I have two continuous variables that I dummy coded into a categorical variable with 2 levels. Each of these variables are coded either 0 or 1 for low and high levels of this variable. Both variables were z-scored to know if they fell below or above the mean.
MeanAboveAvo <- ifelse(Dataframeforstudy2$avo < 0, 0, 1)
MeanAboveAnx <- ifelse(Dataframeforstudy2$anx < 0, 0 , 1)
My question is how do I dummy code these two variables together? I want to create a single variable with 4 different levels using these two variables (MeanAboveAvo & MeanAboveAnx). I want a single variable that is coded with either 1,2,3,4 and the 1 is (0,0), 2 is (0,1), 3 is (1,0) and 4 is (1,1).
My code is this:
stats <- while(MeanAboveAnx = 0 || MeanAboveAvx = 1) {
if(MeanAboveAnx = 0 & MeanAboveAvo = 0 ){
1
}
else if (MeanAboveAnx = 0 & MeanAboveAvo = 1){
2
}
else if(MeanAboveAnx = 1 & MeanAboveAvo = 0){
3
}
else {
4
}}
It is not coding it at all and I am getting an error message. What can I do differently to get the results I want?
Thank you for your help in advance!