Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Argument "No" is missing, with no default

Tags:

r

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$Treatment1.class<-with(z, ifelse(TRTCD1 == 0 & TRTCD1 == 40, 1,
    ifelse(TRTCD1 >= 10 & TRTCD1 <= 30 & TRTCD1 == 50, 2)))

On running these code, I am getting the error:

Argument "No" is missing, with no default

Here, Treatment1.class is a new variable in table z which holds the output of the class.

How to fix this issue?

like image 204
Mukhtar Ahmed Avatar asked Sep 29 '22 05:09

Mukhtar Ahmed


1 Answers

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.

like image 141
Jaehyeon Kim Avatar answered Oct 10 '22 20:10

Jaehyeon Kim