[R] Conditionally incrementing a loop counter

Bert Gunter gunter.berton at gene.com
Thu Dec 27 23:04:50 CET 2007


Please read the posting guide and provide a simple reproducible example as
it asks you to. Very likely a loop is not even needed.

-- Bert Gunter
Genentech, Inc. 

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of Mike Jones
Sent: Thursday, December 27, 2007 1:35 PM
To: r-help at stat.math.ethz.ch
Subject: [R] Conditionally incrementing a loop counter

Hi,
I am trying a for loop from 1 to 100 by 1. However, if a condition does
not get met, I want to "throw away" that iteration. So if my loop is
for (i in 1:100)
and i is say, 25 and the condition is not met then I don't want i to go
up to 26.  Is there a way to do that? I can't seem to manually adjust i
because from what I understand, R creates 100 long vector and uses that
to "loops thru" and I'm not sure how to get at the index of that vector.
Any suggestions? Thanks in advance.










Mike Jones
Westat
1650 Research Blvd. RE401
Rockville, MD 20850
Ph: 240.314.2312


	[[alternative HTML version deleted]]

______________________________________________
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