[R] how to break the loop using sapply?

PO SU rhelpmaillist at 163.com
Fri Oct 10 07:24:49 CEST 2014


Dear expeRts,
   i  use sapply for loop, and i want to break it when i needed, how to do that?  e.g.

sapply( 1:10, function(i) {
if(i==5) break and jump out of the function sapply
} )

I want to do it because i have to loop 1000000 times, but i don't know when it will break, that means, it may need break at i=5 or at i=50000, for the possible of the  last case, i don't use for loop, because it slow(is it right?).
So,if you happen to know it ,may you help me?


--

PO SU
mail: desolator88 at 163.com 
Majored in Statistics from SJTU


More information about the R-help mailing list