Nested ifelse statement

前端 未结 9 1421
逝去的感伤
逝去的感伤 2020-11-22 04:02

I\'m still learning how to translate a SAS code into R and I get warnings. I need to understand where I\'m making mistakes. What I want to do is create a variable which summ

9条回答
  •  清歌不尽
    2020-11-22 04:29

    The explanation with the examples was key to helping mine, but the issue that i came was when I copied it didn't work so I had to mess with it in several ways to get it to work right. (I'm super new at R, and had some issues with the third ifelse due to lack of knowledge).

    so for those who are super new to R running into issues...

       ifelse(x < -2,"pretty negative", ifelse(x < 1,"close to zero", ifelse(x < 3,"in [1, 3)","large")##all one line
         )#normal tab
    )
    

    (i used this in a function so it "ifelse..." was tabbed over one, but the last ")" was completely to the left)

提交回复
热议问题