mardi 30 janvier 2018

Loop with if statement in R

I did loop with if statement as you can see in the code

for (j in  2:4){
  for (i in 1:5-j){
    if (B[i,5-j]>10){   
        A[i,j] = 0
    }else{
       A[i,j] = 2
    }
  }
}

But it doesn´t work.

In if (B[i, 5 - j] > 115) { : the condition has length > 1 and only the first element will be used

I dont know how it works fine

anyone could help?

thanks

Aucun commentaire:

Enregistrer un commentaire