Displaying 20 results from an estimated 1000 matches similar to: "Very simple question R5 setRefClass and Initialize"
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 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]]
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 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
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
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 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
2014 Feb 01
1
Running examples with R5 constructor from package failing
I am having an issue with reference classes (R5) in a package I am developing. They have both been illustrated in the `roxygentest` package I've got hosted on Github [1].?
When I run `R CMD check .` on the source directory of my package I am told that:
> Error: could not find function "Blob"
However, when I install and load the package, I can successfully run the command in the
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
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 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 Nov 09
3
Mongo adapter
I have setup mongo database and want to know which one would be best
adapter ( mongo_mapper , mongoid, dm-mongo-adapter ) in terms of
Associations, include option for eager-loading .
--
Regards
Mukesh Paras Singh
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to
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
2005 May 27
2
imap disconnects on my account only
Talk about personal problems!
I am using dovecot-0.99.13-4.FC2, and everything has been going fine
for months. Earlier this afternoon, Thunderbird's status pane would
say 'Sending authenticate login information...' and I would no longer
receive email.
When I checked with others, they were fine and dandy.
I tried kmail, evolution, and even tried webmail. All had connection errors.
2014 Oct 05
2
Using Rtools with gcc 4.8.3
I started working on some R bindings for mongo-c-driver [1]. The C
library compiles fine on Ubuntu Trusty (gcc 4.8.2) and osx (clang),
however on my windows machine (gcc 4.6.3 from Rtools 3.1) it fails
with: 'INIT_ONCE_STATIC_INIT' undeclared. Google suggests that this
might be a problem in older versions of mingw-w64. So I grabbed a copy
of mingw-w64 version 4.8.3 and indeed, here the
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
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
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,
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