Re: [R] how to get a primitive function object

2009-01-23 Thread Yi Zhang
On Fri, Jan 23, 2009 at 2:50 PM, Duncan Murdoch wrote: > External pointers are the standard way to do that. You don't need to worry > about reference counting, R's garbage collector will call a finalizer when > it doesn't need the object any more. > > I think the usual example of this is the ROD

Re: [R] how to get a primitive function object

2009-01-23 Thread Yi Zhang
On Fri, Jan 23, 2009 at 9:40 AM, Wacek Kusnierczyk wrote: > you might want to specify what 'completely unrecoverable' means, and > what approaches are allowed. > > for the former, i guess that: > - 'incompletely recoverable' means that there is at least one function > name in the global environme

Re: [R] how to get a primitive function object

2009-01-23 Thread Yi Zhang
On Fri, Jan 23, 2009 at 5:15 AM, Patrick Burns wrote: > If I understand properly, you want '<-' to be > a generic function, which it currently isn't. > There may be a way to fake that (I can't think > of any). > > But I'm wondering if you should rethink what > you want. The only reason that I can

Re: [R] how to get a primitive function object

2009-01-22 Thread Yi Zhang
> 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 >

Re: [R] how to get a primitive function object

2009-01-22 Thread Yi Zhang
On Thu, Jan 22, 2009 at 4:17 PM, Wacek Kusnierczyk wrote: > Duncan Murdoch wrote: >> 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 ho

Re: [R] how to get a primitive function object

2009-01-22 Thread Yi Zhang
On Thu, Jan 22, 2009 at 3:06 PM, Duncan Murdoch wrote: > > 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

[R] how to get a primitive function object

2009-01-22 Thread Yi Zhang
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

Re: [R] getting caller's environment

2009-01-21 Thread Yi Zhang
) > x <- 2 > g() # 1 > > On Wed, Jan 21, 2009 at 5:45 PM, Yi Zhang wrote: >> Hello, >> >> I'm writing a function like this: >> >> f<-function(x,y,...) { >> ... >> assign(x,y,envir=?) >> } >> >> I need the caller (of

[R] getting caller's environment

2009-01-21 Thread Yi Zhang
Hello, I'm writing a function like this: f<-function(x,y,...) { ... assign(x,y,envir=?) } I need the caller (of f) 's environment for the "?" so that the assignment is done at the right place. To be specific, when the code "f(x,1)" appears in environment A, I need the assignment of 1 to x happen