lundi 3 juillet 2017

If Else/Statements Within a loop

I am trying to write an If/Else statement within a loop. I am having trouble with identifying the condition using i from the loop. I'd like the next column in the dataset to print out "yes/no" based on whether or not the p.value is significant. Can anyone help?

res3=matrix(0,13,2)
for (i in 1:13)
{
  mk=MannKendall(data.trim[,i+1])
  res3[i,1]=mk$sl
  res3[i,2]=if(mk$sl[i] <= 0.05){
  print("yes")
  } else {
  print("no")
  }
  }

Aucun commentaire:

Enregistrer un commentaire