s-news
[Top] [All Lists]

Re: Repeating a function

Subject: Re: Repeating a function
From: "Martin H. H. Stevens" <hstevens@rci.rutgers.edu>
Date: Tue, 12 Dec 2000 12:09:18 -0500
Cc: paul hughes <u7n96@hotmail.com>, s-news@lists.biostat.wustl.edu
References: <F283jFbUcOV1EetVoMD00014baf@hotmail.com>
How about...

1. Decide on the num,ber of repetitions
reps <- 1000

2. Make a data frame to hold the results
df <- data.frame(result1=numeric(reps))

3. iterate the function. The following will perform the function "reps" times 
using the
same input each time. Aftering reading about "lapply" and "for", look at page 
826-7 of
the S-PLUS programmer's guide.

for(i in 1:reps) df[i] <- function()


paul hughes wrote:

> Hi all,
>
> I have a function in s-plus.  Is there a way in s to define the amount of
> repititions s should do and then get an average of the outputs?
>
> Paul H
> _____________________________________________________________________________________
> Get more from the Web.  FREE MSN Explorer download : http://explorer.msn.com
>
> ---------------------------------------------------------------------
> This message was distributed by s-news@lists.biostat.wustl.edu.  To
> unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
> the BODY of the message:  unsubscribe s-news

--
Dr. M. Henry H. Stevens
Postdoctoral Associate
Department of Ecology, Evolution, & Natural Resources
14 College Farm Road
Cook College, Rutgers University
New Brunswick, NJ 08901-8551

email: hstevens@rci.rutgers.edu
phone: 732-932-9631
fax: 732-932-8746



<Prev in Thread] Current Thread [Next in Thread>