[R] how to get a primitive function object

Duncan Murdoch murdoch at stats.uwo.ca
Thu Jan 22 21:06:56 CET 2009


On 1/22/2009 2:41 PM, Yi Zhang wrote:
> Hi,
> 
> I want to create an alias for the "<-" function and then later
> overwrite it. Any idea how I can get the "<-" function object? I know
> for other functions it's easy, something like "f <- seq" will do; how
> really no clue for this one. Thanks!

get("<-") will give it to you, and

`<-` <- function(x, y) cat("x=", x, "y=", y, "\n")

will change it -- and will probably be the last effective thing you do 
in that session, unless you're really careful:

 > x <- 1
 > x
[1] 1
 > `<-` <- function(x, y) cat("x=", x, "y=", y, "\n")
 > x <- 3
x= 1 y= 3
 > x
[1] 1
 > # now what?? &%#*
 > q("no")

Duncan Murdoch




More information about the R-help mailing list