[R] Evaluate output after each rep()

Matthew MacManes macmanes at berkeley.edu
Mon Feb 6 18:03:08 CET 2006


Hi R-Help,

I'm trying a develop a test simulation where i evaluate the probability 
of not getting a value of 100 from the function rbinom(6000, 200, .5) 
[indeed, a very small probability].  At the end of each rep, I would 
like to evaluate the output, continue with the loop if the output 
contains the value 100, stop if the output lacks a 100.

How do I get R to evaluate the output after each rep?


 >sim <- function(nn){
 >   for (ii in 1:nn){
 >      ee=rep(rbinom(6000, 200, .5), ii)
 >         if (any(ee==100))
 >      }

Thanks,
Matt MacManes
********************************************************
Matthew D. MacManes
PhD Student
UC- Berkeley
Department of Integrative Biology
Museum of Vertebrate Zoology
3101 VLSB #3140
Berkeley, CA 94720
(510)642-7782
EMAIL: macmanes at berkeley.edu
WEBSITE: http://ib.berkeley.edu/labs/lacey/




More information about the R-help mailing list