Re: [R] alias for a class

From: Duncan Murdoch <murdoch_at_stats.uwo.ca>
Date: Fri, 14 Mar 2008 06:29:11 -0400

Christophe Genolini wrote:
> Hi the list
>
> Is it possible to give two names for a class ? One long name for using
> in programmation, and one short name for the "quick and durty" uses ?
>
Not easily.
> With function, we can do
>
> mcf <- myCoolFunction <- function(x)....
>
That creates a new function which is a copy of the old one. If one of them changes later, the other won't change, so it's not really an "alias".

The trouble with trying to do this with classes is that a class isn't a simple thing in R. In S3, it's just a name that can be used in lots of places. S4 is more structured, but still a class definition is fairly spread out.

So you could probably write a function that tracked down and copied all the pieces, but it's not easy.
> With class, I define "clusterizedLongData", I want to use it with the
> full name when I am writing my code, but I would like something like cld
> when I make a demo, or when I try things on console... Is it possible ?

Isn't it really the job of your text editor to make it easy to type well chosen names? The GUIs in Windows and on the Mac can do name completion, so you don't need a lot more typing for the long name than the short one. As far as I know ESS can do the same, and there are probably others too. If you're not using one of those, you should be.

Duncan Murdoch



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 Fri 14 Mar 2008 - 10:56:36 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 Fri 14 Mar 2008 - 11: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