Re: [R] Passing function to tapply as a string

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Mon, 10 Mar 2008 12:04:18 -0400

Also note that there is match.funfn in the gsubfn package. That allows you to also pass functions defined as formulas:

e.g.

library(gsubfn)
f.at.four <- function(f) match.funfn(f)(4)

f.at.four(sqrt) # 2
f.at.four("sqrt") # 2
f.at.four(~ x^.5) # 2 - uses function(x) x^.5

See homepage, ?match.funfn and the vignette.

On Mon, Mar 10, 2008 at 11:46 AM, Yuri Volchik <yuri.volchik_at_gmail.com> wrote:
>
> Thanks,
>
> match.fun is what i was looking for :-)
>
>
>
>
>
>
> Or perhaps:
>
> myfun <- function(fname, ...)match.fun(fname)(...)
>
> On 07/03/2008, Richard.Cotton_at_hsl.gov.uk <Richard.Cotton_at_hsl.gov.uk> wrote:
> > > Was wondering if it is possible to pass function name as a parameter
>
>
> --
> View this message in context: http://www.nabble.com/Passing-function-to-tapply-as-a-string-tp15891151p15950836.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.
>



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 10 Mar 2008 - 16:09:31 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 10 Mar 2008 - 16:30:22 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