Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Compute and re-code into new variables in JASP

Hi.

Could somebody help me🙏.

How do I go about to:

a) create a new nominal (binary) variable from a scale variable. So, I have an age variable (denoted as year of age) and I want to dichotomize this to a nominal variable with two levels, thus, under or equal to the mean age =1 and over the mean age = 2.

b) collapse an ordinal scale (Likert) with five steps to an ordinal scale with three steps. Thus, I want 1 & 2 =1, 3=2 and 4 & 5 =3.

Grateful for some help :-)

Per

Comments

  • For others who may land here: in the meantime this was addressed at https://github.com/jasp-stats/jasp-issues/issues/1844

    E.J.

  • edited October 2023

    Hi@vandenman

    You helped me earlier on the GitHub post a above (it is closed now) as I wanted to create a new variable where I cluster 5-level data to 3-level data. Thus, 1 & 2 =1, 3=2 and 4 & 5 =3. 

    You gave me a great tip with the following R code (that I have used so many times since, despite I hate syntax and coding):

    ifElse(facFive <= 2, 1, 

    ifElse(facFive <= 3, 2, 3)

    )

    Could you just explain the mechanics behind the codes. I can’t get my head around it. In my logic I ask the program to:

    • If the variable is less or equal to 2, make it a 1
    • If the variable is equal to 3, make it a 2
    • If the variable is more or equal to 4, make it a 3

    Could you explain the like I was a kid?🤪🙏🏻

    All the best

    Per

  • Hi Per,


    No worries! The key is to realize that the two statements are nested, so it is actually one statement like so:

    ifElse(facFive <= 2, 1, ifElse(facFive <= 3, 2, 3))

    We can also see this as a decision tree, like below:

    You start at the top and ask the question, is this value <= 2? If yes, you go left, and if no you go right. If you go left, you end up with 1 and are done. If no, you ask another question, is this value <= 3? If yes, you go left and end up at 2. If no then you go right and end up at 3. In general, you repeat this until there are no more questions and you are at a value. We repeat this process for each row in the dataset.


    I hope this makes things more understandable, but let me know if anything else is unclear!

    Don

  • @vandenman

    Thanks Don🙏🏻. That was extremely helpful😍.

    All the best

    Per😎

  • Hi, I just posted:

    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?

    Could I use this code to solve my question?

    Many thanks in advance.

  • Hi Ananda,


    You could create multiple computed columns, one for each new variable you want.

    If that is not what you meant, could you provide an example?


    Best,

    Don

  • Hi, 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. 

  • 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?

    I would do the following:

    and then filter out the missing values before running the analysis.

  • THANK YOU SO MUCH!

    I'll give it a try after dinner and let you know!

  • I've tried following

    ifelse(LonelinessTOTAL ≥ 3 & LonelinessTOTAL ≤ 5,

    "NonLonely",

    ifelse(LonelinessTOTAL ≥ 7 & LonelinessTOTAL ≤ 9,

    "Lonely,

    NA)

    )

    But it gives me the following error:

    Error: Error in parse(text = .rCode): <text>:1:61: unexpected input

    1: local({local({;calcedVals <- {ifelse(LonelinessTOTAL ≥


    What am I doing wrong?

  • Hi, thank you so much for your help. The code script you gave me didn't work exactly that way but with a lot of help I changed a couple of things and it worked. I'm using the following script:

    LonelinessExtremes <- ifelse(LonelinessTOTAL >= 3 & LonelinessTOTAL <= 5,

    "NonLonely",

    ifelse(LonelinessTOTAL > 6 & LonelinessTOTAL <= 9,

    "Lonely",

    NA))

    I'll leave it here in case somebody needs it and maybe if you have access to the GitHub page (I don't for some reason) post it there as well.

    Have a lovely week,

    Ananda.

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games