[R] how does while work
snow at fisher.byu.edu
Fri Mar 22 16:52:11 CET 2002
On Thu, 21 Mar 2002, Liaw, Andy wrote:
> What he wanted is a mechanism to "watch" for a condition on a variable, and
> stop execution as soon as that condition is TRUE, regardless of where in the
> program. The only thing that I know of that sort of does this is inside
> gdb, the GNU debugger. AFAIK this is impossible. If anyone has better
> idea, I'd like to hear about it, too.
You can use "next" and "break" inside of a loop to change the flow (next
goes on to the next iteration, break jumps completely out of the
loop). Inside of a function you can use "return" to stop execution of the
function early (look at the definition of mean.default, it uses return to
stop processing if the trim is 0.5 or greater).
using these with well designed loops should allow you to jump out anywhere
that you need to.
Greg Snow, PhD Office: 223A TMCB
Department of Statistics Phone: (801) 378-7049
Brigham Young University Dept.: (801) 378-4505
Provo, UT 84602 email: gls at byu.edu
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
More information about the R-help