[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:
>http://r.789695.n4.nabble.com/While-loop-working-with-TRUE-FALSE-tp4348340p4348340.html
>Sent from the R help mailing list archive at Nabble.com.
>
>______________________________________________
>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.



More information about the R-help mailing list