You are combining too many loop constructs: perhaps you just want to use for and break.
Of course, in your case it's much faster to write which(r == z) or which.min(r == z) Michael On Wed, Feb 1, 2012 at 10:55 AM, Chris82 <rubenba...@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@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. ______________________________________________ R-help@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.