Hello R helpers,

I have a quick question about loop and next

In my loop, I have some random generation of data, but if the data doesn't
meet some condition, then I want it to go next, and generate data again for
next round.

# just an example..
# i want to generate the data again, if the sum is smaller than 25
temp=rep(NA, 10)
for(i in 1:10)
{
dt=sum(rbinom(10, 5, 0.5))
while (dt<25) next
temp[i]=dt
}

I also tried while(dt<25) {i=i+1}
But it doesn't seem right to me, since it running nonstop. Any solutions ?
Thanks for helps!
Carrie--

        [[alternative HTML version deleted]]

______________________________________________
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.

Reply via email to