[Rd] How to force dispatch to an internal generic?
Dear R-devel, I have a class 'myClass' in R that is essentially a list with pre-specified structure. It has an assignment operator which is going to do some things and then should assign the value using the regular list assignment operator `$<-.myClass`<-function(x,i,value){ # do some pre-processing stuff # make the assignment using the default list assignment x[[i]]<-value x } But I can't actually use x[[i]]<-value as it will dispatch to the already existing [[<-.myClass method. In similar S3 dispatching cases, I've been able use UseMethod or specifically call [[<-.list, or [[<-.default but those don't seem to exist because $<- and [[<- are primitive generics, right? I couldn't figure out a way to effectively call call NextMethod, and I assume calling .Primitive("$<-") is not appropriate. My current solution mirrors $<-.data.frame `$<-.data.frame` <- function (x, name, value) { cl <- oldClass(x) class(x) <- NULL x[[name]] <- value class(x) <- cl x } but according to tracemem(), this is triggering three deep copies of myClass objects (which can be expensive as the object is often very large ) with each $ assignment instead of one. Is there a better way to dispatch the assignment to the default assignment method? Note: I previously posted the same question at http://stackoverflow.com/questions/20627776/how-to-force-dispatch-to-an-internal-generic-in-r thanks for your help, -skye __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Fwd: How to check if R interpreter is initiated
Hi R-Developers , I am using R-3.1 , moved from R-2.15 . I am facing a problem which I have raised in R bug report with bug 15596 . My problem is how to check if R is initiated before initiating R I am embedding R in parallel environment and reusing process already running to reduce overhead . Each process is running infinitely. So when a process is reused,it finds R is already initialized there and throws the error. Till 2.15 it was solved using R_Is_running variable . So I am assuming there should be some flag or return value in R-3.0.2 which provides the user with information if already initialized . Anyone has faced the problem ? It will be great if anyone could suggest alternate solution to this problem for R-3.0. Thanks, Sandy [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Fwd: How to check if R interpreter is initiated
On 13-12-20 2:00 PM, Sandip Nandi wrote: Hi R-Developers , I am using R-3.1 , moved from R-2.15 . I am facing a problem which I have raised in R bug report with bug 15596 . My problem is how to check if R is initiated before initiating R I am embedding R in parallel environment and reusing process already running to reduce overhead . Each process is running infinitely. So when a process is reused,it finds R is already initialized there and throws the error. Till 2.15 it was solved using R_Is_running variable . So I am assuming there should be some flag or return value in R-3.0.2 which provides the user with information if already initialized . Anyone has faced the problem ? It will be great if anyone could suggest alternate solution to this problem for R-3.0. As you've already been told: just maintain your own variable for this. Before initializing R, set it to 0. After initializing R, set it to 1. Duncan Murdoch __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel