similar to: possibly invalid assertion in setRefClass?

Displaying 20 results from an estimated 1000 matches similar to: "possibly invalid assertion in setRefClass?"

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 <-
2011 Oct 31
1
Question about copying reference objects using the initialize method
Dears, I have a question about copying reference objects using the initialize method. 1) If the latter has no arguments, there is no problem to copy an object. myClass = setRefClass("myClass", fields = list(value = "numeric") ) myClass$methods(initialize = function(...){ ? value <<- 1 ? callSuper(...) }) newObject = myClass$new() newObject$value = 2 copyObject =
2010 Nov 17
2
Reference classes: accessor functions via 'getRefClass(...)$accessors(...)'
Hi there, I''d like to choose between an "static" and "dynamic" access of a reference class field, say ''a''. myObj <- getRefClass("Blabla")$new() Static: myObj$a Dynamic: myObj$a.get() where the function retrieves the data from a database (or some other location), stores it to a buffer and
2012 Nov 08
1
Dabbling with R5 setRefClass - Inheritance problems
Hello, I wrote a class like so: > rcfdpsuperclass <- setRefClass( > Class="rcfdpsuperclass", > fields = list( > RcfpdVersion = "character"), > methods = list( > initialize = function(){ > 'Populates fields with defaults and lock as appropriate' > initFields( > RcfpdVersion =
2011 Jun 29
1
Ref Classes: bug with using '.self' within initialize methods?
Dear list, I'm wondering if the following error I'm getting is a small bug in the Reference Class paradigm or if it makes perfect sense. When you write an explicit initialize method for a Ref Class, can you then make use of '.self' WITHIN this initialize method just as you would once an object of the class has actually been initialized? Because it seems to me that you can not.
2011 May 27
1
Reference Classes/S4 Classes: can method dispatch check superclasses BEFORE resorting to method for "ANY"?
Dear list, is it possible that method dispatch checks for superclasses/virtual classes before checking "ANY"? I'd like to build a generic initialization method for all my Reference Class (say "MyDataFrame") objects by having them inherit from class, say "MyRefClassVirtual" (which would have to be a virtual S4 class; there are no virtual Reference Classes,
2012 Jun 25
1
Very simple question R5 setRefClass and Initialize
Hi, New to this list, and glad I found R5 which si a great improvement to R for my work. Something seems odd anyway, when I do a setRefClass, the initialize method execute at the class definition. I would like it to execute only when an instance is created. How can I do that? I found no way to test if the code execution is when the class definition happens or when a $new instance is created.
2010 Nov 24
2
Reference Classes: how to clone/copy instances?
Dear list, I don't know what's the correct term for this in the OOP context, but is it possible to "clone"/copy an instance of a reference class (say 'a') so that I get an *autonomous* second instance 'b'? Autonomous in the sense that changes to 'a' do not affect 'b'. I know that this is somewhat against the pass-by-reference paradigm, but the
2010 Oct 28
2
Reference Classes: Generalizing Reference Class Generator objects?
Is it possible to override the $new(...) in the reference class generator? I have tried adding a "new" method to the methods of the class, but that is obviously not correct. I have also tried adding it to the class generator, but the class generator still uses the default constructor. As a simple example, this is the current interface: TestClass <- setRefClass
2010 Nov 23
1
Reference Classes: removing methods -> implications for objects/instances of that class
Dear list, just to make sure that I understand 'unregistering' methods for S4 reference classes correctly: If I registered a method and want to 'unregister' (i.e. remove) this method again, objects/instance created of the respective class still feature the removed method until I do an explicit reassign ('my.instance <- getRefClass("Classname")$new()'), right?
2011 May 04
1
General "nil" reference class object
Dear John and others, I've been wondering about whether there's any way to indicate a "nil" reference class object, which will represent "no value", and be tested for, but not fail the internal type checking. NULL is the obvious choice (or seems so to me), but can only be used if an explicit class union is created: > Foo <- setRefClass("Foo") > Bar
2011 Feb 03
2
Creating a reference class object from a class definition in a package fails
Hi, I'm trying to create a package that contains reference class definitions from which users can create reference objects, but there seems to be something awry. My toy example creates an empty package via package.skeleton('TestClass') to which I add the following R code: TestClass <- setRefClass('TestClass',fields=c('name')) Unfortunately my R console output
2013 Mar 28
1
Ref classes initFields has incorrect environment?
As suggested by the following code: A <- setRefClass("A", fields = list(x = "logical"), methods = list(initialize = function(...) { x <<- FALSE initFields(...) })) A$new() # Works as expected quote <- as.character A$new() # Error in function (value) : # invalid replacement for field ?x?, should be from class ?logical? or a subclass (was class
2011 Aug 05
1
initFields() method no longer coerces arguments in R-devel
Dear all, I've just had a package update bounced from CRAN because of a recent change in R-devel which seems to affect the behaviour of the initFields() reference class method. (The change must be very recent because I tested the package on a week-old build of R-devel.) It seems that the method no longer coerces its arguments to the expected type of each field. For a simple example: > Foo
2011 Sep 24
1
Can't reliably use RefClass methods in Snowfall
Greetings, I am trying to use Reference Class methods in Snowfall, using R 2.12.1 on Ubuntu Natty. Using then directly seems to work (stanza 2 below), but using them indirectly does not (stanza 3 below). I get an "attempt to apply non-function" error. In addition to exporting the instance of the object I created to the Snowfall slaves, I also made several attempts to export the
2014 Sep 21
1
Bug in new behaviour for all.equal and environments?
Hi R-devel, The following code: all.equal(baseenv(), baseenv()) gives the error when run in a clean R session with latest R-devel (r66650): kevin:~$ R --vanilla --slave -e "all.equal(baseenv(), baseenv())" Error in all.equal.envRefClass(target[[i]], current[[i]], check.attributes = check.attributes, : attempt to apply non-function Calls: all.equal ...
2010 Nov 21
1
reference classes: question on inheritance
Dear list, I have a reference class which should act as a "generic" superclass for other classes. I've read the respective section at ?setRefClass and put the name of the superclass to the 'contains' argument of an example subclass (see class defs below). Classnames are set in a way that shouldn't result in collation issues (virtual def sourced before superclass def
2012 Jun 19
1
Reference classes and memory consumption
Dear All, It seems that reference classes consume a lot of memory which became a problem for my rather extensive simulation. I prepared a small example. An instance of this minimal class uses about 20K on disk. rm(list=ls(all=TRUE)); MySmallClass = setRefClass("MySmallClass", fields = list( myField = "numeric" ), methods = list( initialize =
2013 Apr 30
1
trace with reference class
Hi The final line of the example in ?setRefClass induces an error: > ## debugging all objects from class mEdit in method $undo() > mEdit$trace(undo, browser) Error in envRefInferField(x, what, getClass(class(x)), selfEnv) : 'undo' is not a valid field or method name for reference class "refGeneratorSlot" $trace tries to embed the trace in the generator object (instead
2012 Feb 21
1
Private Variables in R5-Classes possible?
Hi list, is there a way to define some kind of private Variable? I would like to prevent the user from manipulating fields on his own, in order to not destroy data structures. The problem is, that as soon as the variable exists in the environment it is accessible via t$secret_value. test <- setRefClass("test", fields=list( secret = function(value){ cat("the function was