Re: [R] filling array with functions

From: peter dalgaard <pdalgd_at_gmail.com>
Date: Mon, 25 Apr 2011 13:06:35 +0200

On Apr 25, 2011, at 12:15 , derek wrote:

> Richard,
>
> that way I will have to write functions manually and that is not possible
> for large number of functions.
>

Well do what he means:

fv <- vector("list",10)
for (i...
{
  ...
  fv[[i]] <- ...
  ...
}

(Your code still won't work as written; V[i] will not be evaluated until you call the function(s), likely to V[10]. Try something like fv[[i]] <- local({zz <- V[i]; function(x) zz - b*a*x}), or play around with eval(substitute(....)) )

> derek
>
> --
> View this message in context: http://r.789695.n4.nabble.com/filling-array-with-functions-tp3468313p3472885.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help_at_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.

-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes_at_cbs.dk  Priv: PDalgd_at_gmail.com

______________________________________________
R-help_at_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.
Received on Mon 25 Apr 2011 - 11:08:47 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 25 Apr 2011 - 16:30:34 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