Message-ID: <971536df0802231536p1819e333o6309c186ef5dffa@mail.gmail.com>
Date: 2008-02-23T23:36:02Z
From: Gabor Grothendieck
Subject: Aliasing a function
In-Reply-To: <f8e6ff050802231440xcbe8597yf99b2fb83e9c2ca3@mail.gmail.com>
formals can be used like this:
f <- g
formals(f) <- pairlist(a=1,b=2,c=3)
On Sat, Feb 23, 2008 at 5:40 PM, hadley wickham <h.wickham at gmail.com> wrote:
> A simple way to alias a function is to do :
>
> g <- function(a = 1, b = 2, c = 3) a + b * c
> f <- function(...) g(...)
>
> but formals (etc) is no longer very helpful. Is there an easy way to
> programmatically create:
>
> f <- function(a=1, b=2, c=3) g(a=a, b=b, c=c)
>
> This comes up in ggplot2 where I alias many functions to hide the fact
> that I'm using proto in the background, and I'd like the aliased
> functions to be a little more user friendly in terms of revealing what
> are valid arguments (and also to match up with the rdoc files which I
> am building).
>
> Any ideas?
>
> Thanks,
>
> Hadley
>
> --
> http://had.co.nz/
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>