Hi,

try this;

output <- list()

times <- 1000

drift <-function(p0=0.4,N=40,ngen=55){
        p = p0
        for( i in 1:ngen){
                p = rbinom(1,2*N,p)/(2*N)
                }
        return( p )
        } 
for(i in 1:times){
result <- drift(0.4, 40, 55)

output <- c(output, list(result))
}

Then, you can use the "output" with unlist() to do analysis. For example
mean(unlist(output))

Helin.

--
View this message in context: 
http://r.789695.n4.nabble.com/Repeating-a-function-tp3456295p3456358.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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