[R] Aliases for arguments in a function

From: <KKThird_at_Yahoo.Com>
Date: Tue 15 Aug 2006 - 22:29:04 EST


Hi all.

I have a function that I would like to use either the argument name as originally defined or another name. Within the function (and other functions) use the argument name as originally written, so I don't want to simply remove the old argument name for the new one, but simply allow the function to treat both argument names as equivalent.

Here is an example:

foo <- function(arg1, this)
{
if(this < 0) stop("this must be positive") return(arg1/this)
}

foo(arg1=5, this=10)

But, I also want foo() to work equivalently with the following (where 'this' and 'that 'are treated as if they were the same): foo(arg1=5, that=10)

Any thoughts would be appreciated.

Thanks,
Ken                  


        [[alternative HTML version deleted]]



R-help@stat.math.ethz.ch 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 Tue Aug 15 22:35:52 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 16 Aug 2006 - 00:21:54 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.