Suppose I have a variable y and a variable i.
y<- c(TRUE, TRUE, TRUE)
i<- 0
Let’s say I would like to test the following if-statement for every boolean condition in y:
if (y) {
i<-1
}
How would I do this? That is, I want i = 1 if every boolean condition in y is TRUE.
If y<- c(TRUE, FALSE,TRUE), then I want the if-statement to evaluate to FALSE and i=0. Does anyone know how would I do this? Currently I getting this warning message:
Warning message:
In if (y) { :
the condition has length > 1 and only the first element will be used.
How would I test the variable y for each of it’s boolean conditions?
You are looking for the
allfunction.