[R] Evaluate output after each rep()

From: Matthew MacManes <macmanes_at_berkeley.edu>
Date: Tue 07 Feb 2006 - 04:03:08 EST

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))
> }

Matt MacManes

Matthew D. MacManes
PhD Student
UC- Berkeley
Department of Integrative Biology
Museum of Vertebrate Zoology
3101 VLSB #3140
Berkeley, CA 94720
EMAIL: macmanes@berkeley.edu
WEBSITE: http://ib.berkeley.edu/labs/lacey/

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Tue Feb 07 04:10:25 2006

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:42:24 EST