Re: [R] Conditionally incrementing a loop counter: Take 2

2007-12-28 Thread Jim Lemon
Mike Jones wrote: Hi, I am trying a for loop from 1 to 10 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:10) and i is say, 4 and the condition is not met then I don't want i to go up to 5. Is there a way to do that? I can't

Re: [R] Conditionally incrementing a loop counter: Take 2

2007-12-28 Thread John Fox
: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] project.org] On Behalf Of Mike Jones Sent: December-27-07 6:08 PM To: Peter Dalgaard Cc: [EMAIL PROTECTED] Subject: Re: [R] Conditionally incrementing a loop counter: Take 2 Since I didn't want the i to increment in the loop when the condition

[R] Conditionally incrementing a loop counter: Take 2

2007-12-27 Thread Mike Jones
My apologies for not including a working example. Here it is: for (i in 1:10){ cat(initial i = ,i,\n) x - runif(1) if (x 0.7){ i - i-1 } cat(second i = ,i,\n) } When I ran this i got what follows, so there were four cases where I wanted the i not to increment. initial

Re: [R] Conditionally incrementing a loop counter: Take 2

2007-12-27 Thread Peter Dalgaard
Mike Jones wrote: My apologies for not including a working example. Here it is: for (i in 1:10){ cat(initial i = ,i,\n) x - runif(1) if (x 0.7){ i - i-1 } cat(second i = ,i,\n) } When I ran this i got what follows, so there were four cases where I wanted the

Re: [R] Conditionally incrementing a loop counter: Take 2

2007-12-27 Thread Mike Jones
,garbage = ,garbage,\n) } -Original Message- From: Peter Dalgaard [mailto:[EMAIL PROTECTED] Sent: Thursday, December 27, 2007 5:36 PM To: Mike Jones Cc: [EMAIL PROTECTED] Subject: Re: [R] Conditionally incrementing a loop counter: Take 2 Mike Jones wrote: My apologies for not including

Re: [R] Conditionally incrementing a loop counter: Take 2

2007-12-27 Thread Peter Dalgaard
- garbage+1 } cat(i = ,i,garbage = ,garbage,\n) } -Original Message- From: Peter Dalgaard [mailto:[EMAIL PROTECTED] Sent: Thursday, December 27, 2007 5:36 PM To: Mike Jones Cc: [EMAIL PROTECTED] Subject: Re: [R] Conditionally incrementing a loop counter: Take 2 Mike Jones wrote