search for: refclass

Displaying 17 results from an estimated 17 matches for "refclass".

Did you mean: defclass
2013 May 01
1
Size of a refClass instance
I'm using refClass for a complex multi-directional tree structure with possibly 100,000s of nodes. The refClass design is very impressive and I'd love to use it, but I've found that the size of refClass instances are very large and creation time is slow. For example, below is a RefClass and normal S4 class....
2011 Oct 07
0
Pb building sets of S4 / RefClass objects with package "sets"
Hi, does anyone know if it is possible to construct sets of S4 objects? It seems the constructor set does not like it: Error in as.vector(x, "character") : cannot coerce type 'environment' to vector of type 'character' Regards Johnny [[alternative HTML version deleted]]
2011 Oct 07
1
Pb building sets of S4 / RefClass objects with package "sets"
Hi, does anyone know if it is possible to construct sets of S4 objects? It seems the constructor set does not like it: Error in as.vector(x, "character") : cannot coerce type 'environment' to vector of type 'character' Regards Johnny PS: by the way, does anyone know where I can find some examples using the cset class from the "sets" package, beside the
2010 Oct 23
1
Plans for tighter integration of reference classes in R.
Hello Everyone! Here are a couple of thought/questions on refClasses integration in R core functionality. First, coexistence with S4: > X <- setRefClass("classX", fields = c("a", "b"), + representation = list(c = "character")) > x <- X$new() > x at c <- "sss" > x An object of...
2011 Sep 24
1
Can't reliably use RefClass methods in Snowfall
...un Stanza 2 below, then stanza 3 will work. I tried emailing the Snowfall author, but have not heard back. Any help is greatly appreciated! Henry Bryant Texas A&M University library("snowfall") library("methods") # set up a simple reference class calculator <- setRefClass("calculator") calculator$methods(do_calc = function(x) {print(x*x)}) my_calc <- calculator$new() wrapper <- function(x) {my_calc$do_calc(x)} # STANZA 2: use snowfall without wrapper -- WORKING #sfInit(parallel=TRUE, cpus=2, type="SOCK") #sfExport("calculator") #...
2011 Mar 10
1
Testing for a reference class object
Hi all, I've constructed the following function to test whether or not an object was created from a reference class: isRefClassObject <- function(x) isS4(x) && is.environment(attr(x,'.xData')) && exists('.refClassDef',attr(x,'.xData')) but I'm unsure if it's a complete test or if there's a better way to test. Regardless, It would be nice to have such a function in the...
2015 Sep 29
1
making object.size() more meaningful on environments?
Hi Gabe, On 09/29/2015 02:51 PM, Gabriel Becker wrote: > Herve, > > The problem then would be that for A a refClass whose fields take up N > bytes (in the sense that you mean), if we do > > B <- A > > A and B would look like the BOTH take up N bytes, for a total of 2N, > whereas AFAIK R would only be using ~ N + 2*56 bytes, right? Yes, but that's still a *much* better situation than the...
2013 Oct 16
1
Internally accessing ref class methods with .self$x is different from .self[['x']]
...function to the object's environment (with some attributes attached), and the latter just return NULL (unless it has already been accessed once with .self$x). Is this how it's supposed to work? Here's an example that illustrates: https://gist.github.com/wch/7013262 TestClass <- setRefClass( 'TestClass', fields = list(a = 'ANY'), methods = list( initialize = function() { e <- environment() pe <- parent.env(e) ppe <- parent.env(pe) # The environment of this object print(ls(pe)) # The environment of the class...
2015 Jun 23
3
Plans to improve reference classes?
Could of requests: 1) Is there any example or writeup on the difficulties of extending reference classes across packages? Just so I can fully understand the issues. 2) In what sorts of situations does the performance of reference classes cause problems? Sure, it's an order of magnitude slower than constructing a simple environment, but those timings are in microseconds, so one would need a
2015 Sep 29
3
making object.size() more meaningful on environments?
Hi, Currently object.size() is not very useful on environments as it always returns 56 bytes, no matter how big the environment is: env1 <- new.env() object.size(env1) # 56 bytes env2 <- new.env(hash=TRUE, size=75000000L) object.size(env2) # 56 bytes env3 <- list2env(list(a=runif(25000000), L=LETTERS)) object.size(env3) # 56 bytes This makes it pretty useless on
2015 Jul 03
1
Are downstream dependencies rebuilt when a package is updated on CRAN?
...se -- something similar to this has actually occurred. When R went from version 3.0.0 to 3.0.1, there was a new function in the methods package named .setDummyField, and reference class objects that were built against methods 3.0.1 received closures that included calls to .setDummyField(). If these refclass objects were saved in a package at build-time, then they would not work on systems with R (and methods) 3.0.0. Because CRAN built binaries on R 3.0.1 after its release, users who were on R 3.0.0 simply could not run some binary packages from CRAN. Their possible solutions were to upgrade R, or inst...
2015 Jun 23
0
Plans to improve reference classes?
> 1) Is there any example or writeup on the difficulties of extending > reference classes across packages? Just so I can fully understand the > issues. Here's a simple example: library(scales) library(methods) MyRange <- setRefClass("MyRange", contains = "DiscreteRange") a_range <- MyRange() a_range$train(1:10) # Error in a_range$train(1:10) : could not find function "train_discrete" where train_discrete() is an non-exported function of the scales package called by the train() method of Discre...
2015 Sep 29
0
making object.size() more meaningful on environments?
Herve, The problem then would be that for A a refClass whose fields take up N bytes (in the sense that you mean), if we do B <- A A and B would look like the BOTH take up N bytes, for a total of 2N, whereas AFAIK R would only be using ~ N + 2*56 bytes, right? ~G On Tue, Sep 29, 2015 at 2:42 PM, Herv? Pag?s <hpages at fredhutch.org> wrote...
2011 Apr 24
0
should I use setRefClass() ?
Hello, I am somewhat new to R programming and a novice C++ programmer. I'd like to know if I should use setRefClass() to manage objects, functions, and data in a very large program I am attempting to code. See: http://stat.ethz.ch/R-manual/R-devel/library/methods/html/refClass.html I like the referential class structure that C++ provides and R seems to provides via setRefClass(). Mainly what I like is that I ca...
2011 Jun 06
1
Reference Classes: shortcut like 'isS4' for Ref Classes?
Dear list, is there a shortcut-function to check whether a class is a Reference Class or not? There's something like this for S4 classes ('isS4(object)'), but I couldn't find anything regarding Ref Classes. Currently, I'm doing it this way, which is a bit clumsy: A <- setRefClass("A", fields=list(X="numeric")) a <- A$new() isRefClass <- function(object, ...){ return(getClass(class(object))@class == "refClassRepresentation") # getRefClass(class(object))@class == "refObjectGenerator" } isRefClass(a) [1] TRUE Regards, Ja...
2012 Apr 13
0
Reference Class import() behaviour
Dear All, In a project I've been working on we've been using Reference Classes and grid extensively. However, something that I have come across is that when using the import() method on refclass objects, it does not work as expected with grid grobs and viewports. I have prepared test cases that illustrate the point but the general idea is that importing appears to work fine for everything except viewports and grid grobs. Code to illustrate the point follows. # This first case is an exam...
2015 Jan 26
2
speedbump in library
>>>>> Michael Lawrence <lawrence.michael at gene.com> >>>>> on Mon, 26 Jan 2015 05:12:55 -0800 writes: > A isNamespaceLoaded() function would be a useful thing to > have in general if we are interested in readable code. An > efficient implementation would be just a bonus. Good point (readability), and thank you for the support! Note