Re: [R] Handling functions as objects

2012-03-29 Thread Julio Sergio
David Winsemius comcast.net> writes: > > > There is also the `do.call` function to construct proper calls from a > character that matches the name of a function > > f1 = function(foo) { > do.call(foo, list(1,2)) >} > > f1("+") > [1] 3 > Thanks David, this information has bee

Re: [R] Handling functions as objects

2012-03-29 Thread Julio Sergio
Gabor Grothendieck gmail.com> writes: > > See ?match.fun > > There is also an enhanced version, match.funfn, in the gsubfn package. > Thanks Gabor! --Sergio. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEAS

Re: [R] Handling functions as objects

2012-03-29 Thread Julio Sergio
Duncan Murdoch gmail.com> writes: > You are seeing the effects of the evaluator and parser being helpful. > When you say > > foo(1,2) > > Thanks Duncan! --Sergio __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-

Re: [R] Handling functions as objects

2012-03-29 Thread David Winsemius
On Mar 29, 2012, at 1:34 PM, Duncan Murdoch wrote: On 29/03/2012 1:02 PM, Julio Sergio wrote: I learnt that functions can be handled as objects, the same way the variables are. So, the following is perfectly valid: > f = function(a, b) { +print(a) +print(b) + } > > f1 = function(f

Re: [R] Handling functions as objects

2012-03-29 Thread Gabor Grothendieck
On Thu, Mar 29, 2012 at 1:02 PM, Julio Sergio wrote: > I learnt that functions can be handled as objects, the same way the variables > are. So, the following is perfectly valid: > >> f = function(a, b) { > +    print(a) > +    print(b) > + } >> >> f1 = function(foo) { > +    foo(1,2) > + } >> >> f

Re: [R] Handling functions as objects

2012-03-29 Thread Duncan Murdoch
On 29/03/2012 1:02 PM, Julio Sergio wrote: I learnt that functions can be handled as objects, the same way the variables are. So, the following is perfectly valid: > f = function(a, b) { +print(a) +print(b) + } > > f1 = function(foo) { +foo(1,2) + } > > f1(f) [1] 1 [1] 2 > I also

[R] Handling functions as objects

2012-03-29 Thread Julio Sergio
I learnt that functions can be handled as objects, the same way the variables are. So, the following is perfectly valid: > f = function(a, b) { +print(a) +print(b) + } > > f1 = function(foo) { +foo(1,2) + } > > f1(f) [1] 1 [1] 2 > I also know that operators are functions, so, I ca