Simple if statement returning “condition has length > 1” error

后端 未结 1 684
我寻月下人不归
我寻月下人不归 2021-01-29 10:48

I have a table where I have a numerical column of whole positive and negative values. I am trying to run a simple if statement where if the value of Yds is less than 10, then a

相关标签:
1条回答
  • 2021-01-29 11:09

    As the error (which is really a warning) suggests, if uses only the first element of a vector for its condition. Take a look at ifelse, which operates directly on vectors and is more appropriate for your task:

    Data$Ydslt10 <- ifelse( Data$Yds < 10, 1, 0 )
    
    0 讨论(0)
提交回复
热议问题