0

Given data:

condition <- rep(TRUE, 10)
varExist <- c(FALSE, rep(TRUE, 9))
cond <- list(c(rep(TRUE, 6) ,rep(FALSE, 4)))

When there is a condition:

condition <- if(varExist[1]){
  condition
}else{
  condition & !cond[[1]]
}

Then I wanted to convert the if statement into ifelse statement:

condition <- ifelse(varExist[1], condition, condition & !cond[[1]])

But the results differ: Expected:

> condition
 [1] FALSE FALSE FALSE FALSE FALSE FALSE  TRUE  TRUE  TRUE  TRUE

but there is:

> condition
[1] FALSE
stakowerflol
  • 979
  • 1
  • 11
  • 20

0 Answers0