Recode a variable into different variables
Do you know how to recode a variable into 2 variables? In SPSS that option is easy (Transform, then, Recode Into Diff Variables) but I'm having trouble finding that option in JASP. One way could be creating a new variable and coding the values as I need them with R code.
Many thanks in advance
Comments
Can you give a concrete example? (If it is not easy with JASP right now it would be a good feature request for our GitHub page; for details see https://jasp-stats.org/2018/03/29/request-feature-report-bug-jasp/)
EJ
Hi Both, I've made a featurette request for a similar problem at:
[Feature Request]: And the ability to recode variables into categories through GUI · Issue #2530 · jasp-stats/jasp-issues (github.com)
Given this appears closely related, might it be a good idea to collect any relevant examples there?
Hi both, I'm so sorry for replying so late. I honestly lost hope of somebody helping me with this and can't use the GitHub page for now. Let's start from the beginning.
I have a variable named LonelinessSUM because it was computed in JASP to have the totals per participant of the short loneliness scale where the minimum score is 3=nonlonely and the max score is 9=severely lonely. When creating a categorical variable with the values 0= for 3,4,5 = nonlonely; and, 1 for 6,7,9 = Lonely was "easy" as I did it manually and it worked. But, now, I need those numbers to be transformed into a categorical variable where 3,4,5 means NonLonely and 7,8,9 means Severely Lonely. This means skipping the scores that are a 6 as I need to go for the extremes for the second round of ANOVAs (repeated measures). How do I do that in JASP?
Don't know if I'm making sense here.
Hi both, I'm so sorry for replying so late. I honestly lost hope of somebody helping me with this and can't use the GitHub page for now. Let's start from the beginning.
I have a variable named LonelinessSUM because it was computed in JASP to have the totals per participant of the short loneliness scale where the minimum score is 3=nonlonely and the max score is 9=severely lonely. When creating a categorical variable with the values 0= for 3,4,5 = nonlonely; and, 1 for 6,7,9 = Lonely was "easy" as I did it manually and it worked. But, now, I need those numbers to be transformed into a categorical variable where 3,4,5 means NonLonely and 7,8,9 means Severely Lonely. This means skipping the scores that are a 6 as I need to go for the extremes for the second round of ANOVAs (repeated measures). How do I do that in JASP?
Don't know if I'm making sense here.
Hi Amanda, Let's assume for a moment, that you want to keep your original non-lonely and lonely variables as they are. One way to make the new categories were six is skipped is to copy nonlonely and lonely to new variables and just slightly vary the name of the new versions. The latest versions of jasp allow for missing values so you just code your sixes as missing in those new variables and then compute the sums in the same way as you did before. Then rerun your analysis. Does that help?
Hi, thanks for replying and your help.
Yesterday, with a lot of help, I figured it out and the R code script I'm using is:
LonelinessExtremes <- ifelse(LonelinessTOTAL >= 3 & LonelinessTOTAL <= 5,
"NonLonely",
ifelse(LonelinessTOTAL > 6 & LonelinessTOTAL <= 9,
"Lonely",
NA))
I'm posting it here in case somebody else needs it.