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!
Is there many functions: See: grep("<-", ls("package:base"), value = TRUE) For 'substring<-': type `substring<-` in R On Thu, Jan 22, 2009 at 5:41 PM, Yi Zhang <yizhang84@gmail.com> 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! > > ______________________________________________ > R-help@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. >-- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[alternative HTML version deleted]]
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
Yi Zhang wrote:> >>>> # now what?? &%#* >>>> >> now you are really motivated to use '=' instead of '<-': >> >> x = 3 >> x >> # 3 >> >> vQ >> >> > > Thanks. That certainly is an option. But I want to preserve `<-`'s > functionality because I'm writing a package and I don't want to limit > the package user's freedom to use `<-`... > >i was sort-of joking, though it's a real option if you want it. but seriously, there's no reason for the &%#* lamenting: x <- 1 '<-' = function(x,y) 0 x <- 2 # 0 .Primitive('<-')(x,2) x # 2 base::'<-'(x, 3) x # 3 base::'<-'('<-', base::'<-') x <- 4 x # 4 vQ
Apparently Analagous Threads
- getting caller's environment
- overwriting '<-' and infinite recursions
- how to get the variance-covariance matrix/information of alpha and beta after fitting a GLMs?
- handle dates in R?
- Generating series of distributions with the same skewness and different kurtosis or with same kurtosis and different skewness?