Re: [Rd] Aliasing a function

2008-02-26 Thread hadley wickham
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", .)) .

Re: [Rd] Aliasing a function

2008-02-24 Thread Tony Plate
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 >

Re: [Rd] Aliasing a function

2008-02-23 Thread hadley wickham
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

Re: [Rd] Aliasing a function

2008-02-23 Thread Gabor Grothendieck
] [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

Re: [Rd] Aliasing a function

2008-02-23 Thread Gabor Grothendieck
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

Re: [Rd] Aliasing a function

2008-02-23 Thread John Fox
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

[Rd] Aliasing a function

2008-02-23 Thread hadley wickham
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