[R] Repeating a function

From: Sclera <kn0wzal0t_at_gmail.com>
Date: Sun, 17 Apr 2011 16:48:14 -0700 (PDT)

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.

R-help_at_r-project.org mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Mon 18 Apr 2011 - 00:35:09 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 18 Apr 2011 - 03:40:31 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive