[R] Repeating a function

Sclera kn0wzal0t at gmail.com
Mon Apr 18 01:48:14 CEST 2011


Hello all,

I currently have this function:

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

I want to repeat it 1000 times, then do some analysis on the results. I've
tried using the rep() function, but that only gives me repeats of the first
value of p. How can I get 1000 values of p for different iterations of the
function?

Thanks in advance

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



More information about the R-help mailing list