[R] While loop working with TRUE/FALSE?

Jeff Newmiller jdnewmil at dcn.davis.ca.us
Wed Feb 1 17:33:59 CET 2012

No. The while loop is only tested after the for loop has completed. Use debug to understand this if it doesn't make sense to you.
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
Sent from my phone. Please excuse my brevity.

Chris82 <rubenbauar at gmx.de> wrote:

>Hi R users,
>is there any possibilty that a while loop is working like that:
>z <- c(0,1,2,3,4,5,6,7,8,9)
>r <- 7
>   while(w == T) { 
>        for ( i in 1:10 ){
>                w <- r == z[i]
>                print(w)  
>        }
>The loop should stop if w == TRUE
>best regards
>View this message in context:
>Sent from the R help mailing list archive at Nabble.com.
>R-help at r-project.org mailing list
>PLEASE do read the posting guide
>and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list