Re: [R] trouble with exiting loop if condition is met

2018-06-29 Thread Kelly Wu
Hi Jim & Don, I was trying to use the break command originally before posting but for some reason it was making almost all of the p-values in the replications non significant. I think I am going to change the flow of the loop so I don’t have to use a break, such as the code Jim wrote. Thanks f

Re: [R] trouble with exiting loop if condition is met

2018-06-28 Thread Jim Lemon
Hi Kelly, You seem to be testing the two "years" independently, so here is a possible solution: npg<-16 futility1<-futility2<-psignif1<-psignif2<-nrep<-0 while(!futility1 && !futility2 && !psignif1 && !psignif2 && nrep < 1) { control_respond1<-sum(runif(npg,0,1) < 0.05) control_respond2<-sum

Re: [R] trouble with exiting loop if condition is met

2018-06-28 Thread MacQueen, Don via R-help
Does this example help? > for (ii in 1:10) { cat( ii,'\n') ; if (ii >3) break } 1 2 3 4 The loop won't stop unless you tell it to stop, and I don't see any place where you told it to stop. -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-42

[R] trouble with exiting loop if condition is met

2018-06-28 Thread Kelly Wu
I am working on a clinical trial simulation with two groups, treatment and placebo, and the outcome is dichotomous (recovery or no recovery) . I would like to stop my loop if either of my conditions are met: 1) futility - there are no responses to treatment in the treatment group. 2) the p-value i