简体   繁体   中英

How to repeat a function five times?

I have a formula and want to repeat it five times, would you mind to help me? the loop is as follow:

ED_Dry= e.divisive(X=Rainfall_Dry,sig.lvl=0.05,R=199,k=NULL,min.size=20,alpha=1)

repeat {
  ED_Annuall= e.divisive(X=Rainfall_annuall,sig.lvl=0.05,R=199,k=NULL,min.size=20,alpha=1)
  if(ED_Annuall$p.values<0.05) {
    print("End of Loop");
    break
  }
  time(5)
}# end of if

Thanks in Advance.

for(i in 1:5){
  ED_Annuall=e.divisive(X=Rainfall_annuall,sig.lvl=0.05,R=199,k=NULL,min.size=20,alpha=1)
  if(ED_Annuall$p.values<0.05) {
    print("End of Loop");
    break
  }
}

Isn't this enough?

You can try this

ED_Dry= e.divisive(X=Rainfall_Dry,sig.lvl=0.05,R=199,k=NULL,min.size=20,alpha=1)
for(int i = 0; i < 5; i++) {
   ED_Annuall= e.divisive(X=Rainfall_annuall,sig.lvl=0.05,R=199,k=NULL,min.size=20,alpha=1)
   if(ED_Annuall$p.values<0.05) {
      print("End of Loop");
      break;
   }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM