Howdy, Stranger!

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

Supported by

Compute a new variable based an ordinal value with r in jasp

Hello, I have a column with a nominal value of 0,1 I want to create another column based on it using r in jasp,

I tried:

if (col1 == 0 ) {1} else {0}

but it gives only one value, I need to somehow map the whole data frame but I'm new to R.

thanks.

Comments

  • For now this works

    ```

    # this code snippet create a new column that has the result of `col1 | col2`

    # start with an empty column

    m<-lapply(1:length(data$col1),function(e) 0)

    for(i in 1:length(m)) {

    if (!is.na(data$col1[[i]]) & data$col1[[i]] =="yes") {m[[i]] = 1}

    if (!is.na(data$col2[[i]]) & data$col2[[i]] =="yes") {m[[i]] = 1}

    }

    m

    ```

Sign In or Register to comment.