Howdy, Stranger!

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

Supported by

ifElse

I am trying to use the ifelse() function to populate a new column in JASP. If the value in Variable is less than 5 I need the value in newColumn2 to be set to 0, else, it shold be set to 1. It's not clear what goes into the "test" argument. It does not appear to work at all like Excel and I can find no documentation on any of the functions on the far right of this window anywhere on the internet.

A clue on how to search this forum without getting every post with the work ifElse in it would be helpful as well.

Thanks much.


Comments

  • I'll forward your post to those in the know.

    E.J.

  • Actually, before I call in outside help, did you inspect these resources?

    and the gifs listed under https://jasp-stats.org/how-to-use-jasp/

    E.J.

  • edited December 2019

    Yes, thanks, I did. I couldn't find anything that was specific to the ifelse function. The functions at the top of the window are clear enough (+,-,<,>, etc.) but the ones on the right, in particular ifelse isn't.

    I tried running the expression using r code:

    ifelse("injuries" > 3,"Yes", "No")

    but only the first row gets the computed value. I'm undoubtedly doing something wrong but I don't know enough about r or JASP to figure it out.

  • OK, that's informative, I'll forward your post.

    E.J.

  • Actually I got the r command to work. Don't know what I was doing before. The expression builder still vexes me. If I can do this with an r function, I'm good but I am curious to see how to expression builder works. Perhaps there's a bug?

    Thanks for your help.

  • Hi Eric,

    The builder requires a logical expression in the "test" argument. Here's an example:

    In this example, I want a column consisting of 0s and 1s. If Happiness < 4, then it needs to return 0 else a 1. Note that Happiness is a continuous variable, which is why ifelse doesn't take it as an argument. One way around this is as follows:

    1. tick ifelse
    2. tick the variable Happiness, which now appears on a new line
    3. I choose the < operator, which is appended to Happiness
    4. Enter 4
    5. Now the statement "Happiness < 4" is a logical which is either TRUE or FALSE
    6. Drag "Happiness < 4" in the "test" clause of ifelse
    7. Enter 0 in the "then" clause, and 1 in the "else" clause of ifelse

    Alternatively,

    1. Tick ifelse
    2. Tick the < operator, which should appear in the "test" clause of ifelse
    3. Drag the variable Happiness into the left-hand side < and enter 4 on the right-hand side
    4. Enter 0 in the "then" clause, and 1 in the "else" clause of ifelse

    Let me know whether this works for you.

    Cheers,

    Alexander

  • Hi Eric,

    here is a small video contribution ...

    Cheers,

    Maurizio

  • Hi Maurizio, are you OK if we add this video to our website and point to it on Twitter?

    E.J.

  • Hi EJ, if you do this, I would be very pleased.

    Do it, thank you.

    Maurizio

  • If you'd like some twitter credits you can send your complete name or twitter handle -- otherwise you'll be acknowledged be Maurizio. BTW, do you have this as a gif? (this is the format we generally use)

  • Hi. This actually does not work in JASP 0.15.0 (Windows 10). It generates an error, as shown below.


    R

  • edited September 2021

    Hi Richard,

    Thanks for reporting this. I've got the same error on mac, so it's safe to assume that it's not platform dependent. I've reported this bug on github see

    https://github.com/jasp-stats/jasp-issues/issues/1430

    There you can find the jasp file that reproduces the error. It also shows the workaround that does work, namely, temp2, which is created by writing the statement `ifelse(VariableA>2,1,0)` in R code. This is of course not ideal, but it'll be taken into account for the next release, or the one shortly thereafter. Thanks again.

    Cheers,

    Alexander

  • edited April 2022

    In case it is helpful. I have posted the same error message with another dataset here: in the JASP stats github:

    ifElse broken in compute column point-and-click interface #1430

    I use JASP teaching a large intro applied stats class. I'm not sure how this reporting process goes so thought I'd post both places. I do not teach them R, so the workaround isn't for this group.

    JASP is a great program for the students. Happy to figure out how to report errors to make it even better. I especially appreciate the recent capacity to edit figures.

    Just waiting for a bar chart with errors (rather than the line graph) but I bet there is somewhere else to go request that.

    Thanks,

    Paula Marentette

  • Thanks. We'll have a small release soon (this mainly fixes some installation issues we've been having, and improves things internally) quickly followed by a release with a lot more new functionality.

    Cheers,

    E.J.

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