[R] stop without error message

Duncan Murdoch murdoch at stats.uwo.ca
Fri Jul 4 14:25:48 CEST 2008


On 7/4/2008 8:04 AM, Eric Ferreira wrote:
> Dear useRs
> 
> How can I stop a loop without printing the 'error' message (givin by stop()
> , for instance) ?

Just put in a break statement, e.g.

 > for (i in 1:100000) {
+   print(i)
+   if (i > 5) break
+ }
[1] 1
[1] 2
[1] 3
[1] 4
[1] 5
[1] 6
 >

Duncan Murdoch



More information about the R-help mailing list