Argument “No” is missing, with no default

前端 未结 2 811
猫巷女王i
猫巷女王i 2021-01-18 23:54

I need to assign values in the variable \"TRTCD1\" in two different classes as 1 and 2, based on the condition as stated in the R programming code below.

z$T         


        
相关标签:
2条回答
  • 2021-01-19 00:20

    My guess is as following.

    ifelse(TRTCD1 == 0 & TRTCD1 == 40,
           1,
           ifelse(TRTCD1 >= 10 & TRTCD1 <= 30 & TRTCD1 == 50, 2, *value if NO*)
    )
    

    Only the case where the second ifelse is TRUE is given.

    0 讨论(0)
  • 2021-01-19 00:26

    This Error tells that else statement is missing which should be written as:

    z$Treatment1.class<-with(z, ifelse(TRTCD1 == 0 & TRTCD1 == 40, 1,
        ifelse(TRTCD1 >= 10 & TRTCD1 <= 30 & TRTCD1 == 50, 2,<else code here>)))
    
    
    0 讨论(0)
提交回复
热议问题