Hi everyone, I am trying to write STATA codes in R. It is actually a very small puzzle, I guess. My original variable generation in STATA looks like this:
I have the same doubt about your question that Pedro raised. I have never used Stata but isn’t "/" an arithmetic operator for division? So in your Stata code that reads x3==1/2, are you not testing if x3=0.5. While in the R code (x3==1|x3==2) is testing if x3 is either equal to 1 or 2?
So, if you are trying to test if x3 (also for x4 and x5) is either equal to 1 or 2 your Stata code should also read x3==1|x3==2, as you have used in the R code.
Thank you all for your responses. I think I didn't give enough info while I asked the question. 1/2 meant integer division. I got the solution now: through the use of x%/%y operator in R. So, my code looks like: