Howdy, Stranger!

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

Supported by


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.


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


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

    and the gifs listed under


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


  • 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


    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.



  • Hi Eric,

    here is a small video contribution ...



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


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

    Do it, thank you.


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

Sign In or Register to comment.