Displaying 20 results from an estimated 2000 matches similar to: "setting invalid fields on reference classes sometimes allowed"
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
2014 Mar 03
1
reference classes, LAZY_DUPLICATE_OK, and external pointers
We (the lme4 authors) are having a problem with doing a proper deep
copy of a reference class object in recent versions of R-devel with
the LAZY_DUPLICATE_OK flag in src/main/bind.c enabled.
Apologies in advance for any improper terminology.
TL;DR Is there an elegant way to force non-lazy/deep copying in our
case? Is anyone else using reference classes with a field that is an
external pointer?
2011 May 04
1
Reference Classes: replacing '.self' with an .Rda image of '.self' from within a method? (was replacing '.self' with an .Rda image of '.self' from within a method?)
Sorry guys,
but I chose a really stupid name before (no "reference classes").
Hope it's okay to re-post.
Cheers,
Janko
>>> ORIGINAL MESSAGE <<<
Dear list,
Is it possible to update or reassign '.self' with an image of '.self'
(e.g. a locally stored .Rda file) from within a method?
I know that this might sound akward, but here's the use
2019 Jun 28
2
methods package: A _R_CHECK_LENGTH_1_LOGIC2_=true error
> On 28 Jun 2019, at 16:03 , Martin Maechler <maechler at stat.math.ethz.ch> wrote:
>
>>>>>> Henrik Bengtsson
>>>>>> on Thu, 27 Jun 2019 16:00:39 -0700 writes:
>
>> Using:
>>
>> untrace(methods::conformMethod)
>> at <- c(12,4,3,2)
>> str(body(methods::conformMethod)[[at]])
>> ## language omittedSig
2019 Jun 27
2
methods package: A _R_CHECK_LENGTH_1_LOGIC2_=true error
Using:
untrace(methods::conformMethod)
at <- c(12,4,3,2)
str(body(methods::conformMethod)[[at]])
## language omittedSig <- omittedSig && (signature[omittedSig] != "missing")
cc <- 0L
trace(methods::conformMethod, tracer = quote({
cc <<- cc + 1L
print(cc)
if (cc == 31) { ## manually identified
untrace(methods::conformMethod)
2011 Apr 07
2
How to debug reference classes?
How do you debug methods of a reference class? I've been using mtrace, which
is excellent, but i cannot figure out how to mtrace a reference class
method. Maybe there is some other way to debug these, for example with
ordinary trace? for now i am only able to use options(error=recover), which
is not giving me idea where exactly in the code i am once i am stopped on an
error.
--
View this
2011 Dec 08
1
Reference class finalize() fails with 'attempt to apply non-function'
This bug appears intermittently in R CMD check when reference classes
have finalize methods. The problem is that garbage collection can be run
after the methods package is no longer available. It affects
(periodically) the Bioconductor AnnotationDbi package as well as
packages that contain Rcpp classes. To reproduce:
library(methods)
a = setRefClass("A",
2011 Dec 09
1
'callNextMethod' in a '[<-' function does not work ?
Hi the list,
I try to use callNextMethod in a setteur ([<-) but it does not work.
Any raison ?
Any other option ?
--- 8< ------------------
### Class B0 ###
setClass("B0" , representation(b0 = "numeric"))
setReplaceMethod("[","B0",function(x,i,j,value){x at b0 <- -value})
a <- new("B0")
a at b0 <- 3
a
a["b0"] <- 3
a
2011 Jun 01
1
possibly invalid assertion in setRefClass?
> setRefClass("Foo", fields = list())
Error in setRefClass("Foo", fields = list()) :
A list argument for fields must have nonempty names for all the fields
In my opinion, the above should not fail. There are no fields.
Thanks,
Michael
[[alternative HTML version deleted]]
2012 Oct 27
2
Class generator functions for reference classes
As of rev. 61035 in r-devel, setRefClass() now returns a generator
function, as setClass() has done since 2.15.0.
The convenient style is now:
mEdit <- setRefClass("mEdit",......)
xx <- mEdit(data = xMat)
instead of
xx <- mEdit$new(data = xMat)
The returned object still has fields and methods accessible as before.
See the "Value" and "Reference Class
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 =
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 Jun 03
2
Bug or feature: using "ANY" as a generic field class (was: '[R] Is there a (virtual) class that all R objects inherit from?)
Dear list,
I was wondering if you could help me out in clarifying something:
Is it possible to use class "ANY" in slots/fields of formal classes if you
a) do not want to restrict valid classes of that field and
b) if you are making explicit use of class inheritance?
It seems to work in simple scenarios but produces errors when class
inheritance comes into play. So I was
2014 Feb 11
2
$new cannot be accessed when running from Rscript and methods package is not loaded
Hi
Accesses the $new method for a class defined in a package fails if the
methods package is not loaded. I have created a test package with the
following single code file:
newTest <- function() {
cl <- get("someClass")
cl$new
}
someClass <- setRefClass("someClass")
(This is similar to code actually used in the testthat package.)
If methods is not loaded,
2020 Mar 27
4
object.size vs lobstr::obj_size
Hi Tomas,
On 3/27/20 07:01, Tomas Kalibera wrote:
> they provide an over-approximation
They can also provide an "under-approximation" (to say the least) e.g.
on reference objects where the entire substance of the object is ignored
which makes object.size() completely meaningless in that case:
setRefClass("A", fields=c(stuff="ANY"))
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
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
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 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