[R] Two names of a function
Göran Broström
gb at stat.umu.se
Wed May 14 10:20:36 CEST 2003
On Wed, 14 May 2003, Ko-Kang Kevin Wang wrote:
> Do you mean something like:
> > sq <- function(x) x^2
> > sq(2)
> [1] 4
> > sq(9)
> [1] 81
> > sq1 <- sq
> > sq1(9)
> [1] 81
No, you are taking a copy of the function. I'm thinking in the lines of
1. an 'alias' mechanism: sq1 <- function() alias(sq), or
2. sq1 calling sq: sq1 <- function(x) sq(x)
but 2. must be done more sophisticated. I foresee problems with
environments and passing the argument list.
Göran
>
>
> On Wed, 14 May 2003, Göran Broström wrote:
>
> > Date: Wed, 14 May 2003 09:59:13 +0200 (CEST)
> > From: Göran Broström <gb at stat.umu.se>
> > To: R-help <r-help at stat.math.ethz.ch>
> > Subject: [R] Two names of a function
> >
> >
> > Is it possible to let a function be known under two names without having
> > two identical copies of the function body?
> >
> > ---
> > Göran Broström tel: +46 90 786 5223
> > Department of Statistics fax: +46 90 786 6614
> > Umeå University http://www.stat.umu.se/egna/gb/
> > SE-90187 Umeå, Sweden e-mail: gb at stat.umu.se
> >
> > ______________________________________________
> > R-help at stat.math.ethz.ch mailing list
> > https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> >
>
>
--
---
Göran Broström tel: +46 90 786 5223
Department of Statistics fax: +46 90 786 6614
Umeå University http://www.stat.umu.se/egna/gb/
SE-90187 Umeå, Sweden e-mail: gb at stat.umu.se
More information about the R-help
mailing list