Makes sense. Simple and works. Thank you Greg.
Sent from my iPhone
> On 20 Dec 2013, at 16:15, Greg Snow <538...@gmail.com> wrote:
>
> My first thought was to use Reduce, but I think for this case that is
> a bit of overkill. You can have a vector or list of functions and
> just use sapply/lapp
My first thought was to use Reduce, but I think for this case that is
a bit of overkill. You can have a vector or list of functions and
just use sapply/lapply on the list of functions then sum the result.
A quick example:
> funs <- c(sin,cos,tan)
> sapply( funs, function(f) f(pi/6) )
[1] 0.50
Onur Uncu [mailto:onuru...@gmail.com]
> Sent: Thursday, December 19, 2013 11:43 AM
> To: William Dunlap
> Subject: Re: [R] A function which is a sum of other functions...
>
> Thanks William. May I please ask why we needed to use lapply inside Reduce?
> It sounds
> like we took a
ct.org [mailto:r-help-boun...@r-project.org] On
> Behalf
> Of Onur Uncu
> Sent: Thursday, December 19, 2013 11:05 AM
> To: r-help@r-project.org
> Subject: [R] A function which is a sum of other functions...
>
>
> Dear R Users
>
> I have a list of functions. Each funct
On Dec 19, 2013, at 11:05 AM, Onur Uncu wrote:
>
> Dear R Users
>
> I have a list of functions. Each function in the list is a function of single
> variable. I would like to create a function (of one variable) which
> represents the sum of all the functions in the list. So, if the functions i
Dear R Users
I have a list of functions. Each function in the list is a function of single
variable. I would like to create a function (of one variable) which represents
the sum of all the functions in the list. So, if the functions in my list are
f1(x),..,f5(x) then I would like a new functio
6 matches
Mail list logo