[R] summing elements in a list of functions

Gabor Grothendieck ggrothendieck at gmail.com
Fri Oct 20 17:21:56 CEST 2006


ttt is a list of functions so each function in ttt is passed in turn to
the anonymous function as argument f.

On 10/20/06, James Foadi <jf117 at york.ac.uk> wrote:
> Many thanks to those who have answered my question.
> Could I ask Gabor and Peter the meaning of:
>
> > sum(sapply(ttt,function(f) f(x)))
>
> I gather that a "mysterious" function f(x) is applied to all components of
> ttt, and sum can act on this modified object. But what is exactly f? And how
> does the list object change?
>
> Cheers,
>
> J
>
> --
> Dr James Foadi
> Department of Physics
> University of York
> York YO10 5DD
>
> email: jf117 at york.ac.uk
> web page: http://www-users.york.ac.uk/~jf117
> Tel: 0044 1904 434622
> Mobile: 0044 7740 678548
>



More information about the R-help mailing list