[R] Infinite loop

2011-03-22 Thread Hosack, Michael
R experts, Hello, I am trying to sample a vector 1:40 without replacement such that no element in the new vector is within 7 units of either of its immediate neighbors. This is part of a larger program I am working on. The following code works well about 65 % of the time (14/40). The problem

Re: [R] Infinite loop

2011-03-22 Thread jim holtman
The simple thing to do is to put a sanity counter in the 'repeat' statement and if you have been through it a certain number of times, then exit. Anytime you have a loop that might run forever, you should have some sanity/watchdog timer on it. On Tue, Mar 22, 2011 at 11:02 AM, Hosack, Michael

Re: [R] Infinite loop

2011-03-22 Thread Martyn Byng
up. Martyn -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Hosack, Michael Sent: 22 March 2011 15:03 To: r-help@R-project.org Subject: [R] Infinite loop R experts, Hello, I am trying to sample a vector 1:40 without replacement

Re: [R] Infinite loop

2011-03-22 Thread Hosack, Michael
could not find any info. on them in the R archives. Thanks again Mike -Original Message- From: jim holtman [mailto:jholt...@gmail.com] Sent: Tuesday, March 22, 2011 1:00 PM To: Hosack, Michael Cc: r-help@R-project.org Subject: Re: [R] Infinite loop The simple thing to do is to put

Re: [R] Infinite loop

2011-03-22 Thread Hosack, Michael
Thank you so much Martyn. Now I can most likely avoid having to rerun my program multiple times. Mike -Original Message- From: Martyn Byng [mailto:martyn.b...@nag.co.uk] Sent: Tuesday, March 22, 2011 1:21 PM To: Hosack, Michael Cc: r-help@R-project.org Subject: RE: [R] Infinite loop

Re: [R] Infinite loop

2011-03-22 Thread jim holtman
:00 PM To: Hosack, Michael Cc: r-help@R-project.org Subject: Re: [R] Infinite loop The simple thing to do is to put a sanity counter in the 'repeat' statement and if you have been through it a certain number of times, then exit.  Anytime you have a loop that might run forever, you should have