Re: [R] stop without error message

From: Duncan Murdoch <murdoch_at_stats.uwo.ca>
Date: Fri, 04 Jul 2008 08:25:48 -0400

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



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Fri 04 Jul 2008 - 12:28:32 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 04 Jul 2008 - 12:31:16 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive