lundi 5 décembre 2016

Conditional if statement in R (& operator)

I am trying to do an if conditional with two conditions in a row:

i<-1
while(i<26){
    if (A[i]>90 & A[i]<98){
        print(i); 
        i<-i+1
    } else {
        i<i+1;
    }

}

}

A is a 5x5 matrix. When I run it on the console it tends to halt and return no value. Maybe there is problem with the loop or logical operator '&'. Does & have the 'AND' functionality in R language?

I would be grateful if you could help me. Thanks!!

Aucun commentaire:

Enregistrer un commentaire