Thanks Tony (and others), for getting me started. I eventually ended up with:
TopLevel$build_accessor <- function(., extra_args = c()) {
layer <- if (.$class() %in% c("geom","stat", "position")) c(
list(mapping=NULL,data=NULL),
compact(list(
geom = if (exists("default_geom", .)) .
Maybe something like this? (though it seems like it might be more
straightforward to do this sort of thing by text-processing a source
file then source'ing it in R).
> f <- function(a, b, c) c(a=a,b=b,c=c)
> attr(f, "source") <- NULL
> f
function (a, b, c)
c(a = a, b = b, c = c)
> g1 <- f
>
On Sat, Feb 23, 2008 at 5:52 PM, Gabor Grothendieck
<[EMAIL PROTECTED]> wrote:
> I assume he wants to be able to change the
> formals although its confusing since the example
> uses the same formals in both cases.
Yes, that was an important point that I forgot to mention! Thanks for
the pointer
] [mailto:[EMAIL PROTECTED]
> > project.org] On Behalf Of hadley wickham
> > Sent: February-23-08 5:40 PM
> > To: R-devel
> > Subject: [Rd] Aliasing a function
> >
> > A simple way to alias a function is to do :
> >
> > g <- function(a = 1, b = 2, c
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 <[EMAIL PROTECTED]> 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
PROTECTED] [mailto:[EMAIL PROTECTED]
> project.org] On Behalf Of hadley wickham
> Sent: February-23-08 5:40 PM
> To: R-devel
> Subject: [Rd] Aliasing a function
>
> A simple way to alias a function is to do :
>
> g <- function(a = 1, b = 2, c = 3) a + b * c
> f <- functio
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