Displaying 20 results from an estimated 50000 matches similar to: "Pb building sets of S4 / RefClass objects with package "sets""
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
2011 Jan 13
1
s3 methods on S4 objects
I have J Chambers wonderful text ( Software for data Analysis) and I've been
trying
my hand at some very routine S4 OOP development.
One of the things I was trying to do was to create some very basic S4
classes. The first
was simply a class that had a data.frame as part of its representation.
setClass("df",representation(dirframe="data.frame"))
The object basically
2009 Oct 19
1
Defining S3-methods for S4-objects: cannot coerce type 'S4' to vector of type 'integer'
In the 'doBy' package there is an esticon() function for calculating linear contrasts for various model types. I have defined an S3-method 'esticon.mer()' for 'mer' objects from the lme4 package. Building the package and invoking the method gives:
> esticon(fm1, c(1,1))
Confidence interval ( WALD ) level = 0.95
Error in as.integer(x) :
cannot coerce type 'S4'
2006 Sep 14
1
attributes of S4 objects
I am having a bit of a struggle deciding when to use attributes with
S4 objects. Clearly the 'class' attribute will always be present.
But it is not clear to me whether the architects of the methods
package intend that other attributes, such as 'names', will still be
used when the S4 implementation is complete.
I notice that, when you create a formal object from an
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. The RefClass requires about 4KB per instance vs 500B for the S4 class --
2008 Jan 31
2
Pb with lapply()
Hi,
If needed, lapply() tries to convert its first argument into a list
before it starts doing something with it:
> lapply
function (X, FUN, ...)
{
FUN <- match.fun(FUN)
if (!is.vector(X) || is.object(X))
X <- as.list(X)
.Internal(lapply(X, FUN))
}
But in practice, things don't always seem to "work" as suggested by
this code (at least to the
2005 Jan 07
1
Destructor for S4 objects?
Hi,
To write a "constructor" for an S4 object, you make an initialize method
which will be called by new. But how would I make a "destructor" method to
be called when the S4 object is garbage collected? I'm looking at
reg.finalizer, but I'm not sure how to make that work for an S4 object.
I want to write a destructor because my S4 object's initialize method
2016 Sep 22
1
as.character.factor and S4 object containing factor
Do I mess up something or is this a bug? If I define an S4 object
that contains "factor", all the tests indicate that it is a factor but
as.character.factor() complains of it being a non-factor...
> setClass("Foo", contains="factor")
> a <- new("Foo", factor(1:3))
> a
Object of class "Foo"
[1] 1 2 3
Levels: 1 2 3
> class(a)
[1]
2006 Oct 26
2
S4 pb in R 2.5.0
Hi,
When playing interactively with the S4 system, I've tried
to define the following class:
> setClass("A", representation("integer"))
[1] "A"
> showClass("A")
Slots:
Name: .Data
Class: integer
Extends:
Class "integer", from data part
Class "vector", by
2009 May 29
1
Problem making a package using S4 objects.
Hello.
I've developed an algorithm in R which I need to package.
The implementation uses S4 objects and it's divided in 5 files.
Everything is working fine when I load the files into the R console but when
I try to make a package I get an error that I don't quite understand.
Here's what I do:
*1.* in R console, I do and get:
> package.skeleton(name='remora')
Creating
2004 May 13
0
using trace() on S4 coerce method
I'm trying to use trace() on an S4 coerce method, but get the error
Error in bindingIsLocked(what, whereM) : no binding for "coerce"
What am I doing wrong? Example code follows.
(I've googled the R mailing lists for "trace coerce" and "trace
bindingisLocked" without finding anything relevant. Perhaps I should
re-define the method in terms of an
2006 Aug 28
2
S4 classes and objects -- fixed structure? No...
Hello.
Suppose you define a new S4-class, say
> setClass("track", representation(x="numeric", y="numeric"))
Don't worry if you have a deja vu, it's from the help page.
Your new class is said to have a fixed structure: two slots, x, and y,
and that should apply to all objects you construct as members of that class.
> tr <- new( "track" )
2009 Jun 30
1
S4 class redefinition
I haven't found much on S4 class redefinition; the little I've seen
indicates the following is to be expected:
1. setClass("foo", ....)
2. create objects of class foo.
3. execute the same setClass("foo", ...) again (source the same file).
4. objects from step 2 are now NULL.
Is that the expected behavior (I ran under R 2.7.1)?
Assuming it is, it's kind of
2012 Oct 18
1
S4 fails to initialize linear hierarchies with intermediate VIRTUAL classes
Initialization of this simple hierarchy
A = setClass("A", representation(x="numeric"))
setClass("B", contains=c("VIRTUAL", "A"))
C = setClass("C", contains="B")
fails (neat that setClass returns generators; I hadn't realized that before!)
> C(A())
Error: evaluation nested too deeply: infinite recursion /
2014 Jul 18
1
capture.output on S4 slot
Hello,
capture.output produces a different result if the S4 object was created with a constructor than if the body of the constructor is copied and pasted.
setClass("TransformParams", representation(
transform = "function",
otherParams = "list")
)
setGeneric("TransformParams", function(transform, ...)
{standardGeneric("TransformParams")})
2010 Jul 21
1
Bug: broken exception handling in S4 methods
Hi all:
we have noticed for quite a while that certain errors cannot be handled
by R try, tryCatch etc blocks, but it was fairly difficult to understand
what were the conditions for this incorrect behaviour. Finally I stabbed
across a very understandable case, which is outlined in the (runnable)
example below.
The main message is: wrapping an S4 method call in a try block will not
help if an
2013 Feb 14
1
mapply error with Math (S4 group generic)
I get an error when using self-defined (not standard) functions with mapply
with S4 objects from the raster package that I develop: "Error in
as.character(sys.call(sys.parent())[[1]]) : cannot coerce type 'closure'
to vector of type 'character'". Does anyone understand why? The problem is
illustrated below. Thanks, Robert
> # First a general example that works
2005 Feb 10
1
Undocumented S4 methods: generic coerce and siglist matrix, Massvector
Hi,
While checking the package I am getting all the time the following
complain about the function:
Undocumented S4 methods:
generic coerce and siglist matrix,Massvector
I have not defined the function nowhere in the R files.
My gues is that this has something to do with the following definition
of the setAs function.
setAs("matrix","Massvector"
,def=
2012 Dec 12
1
Lost in S4 and S3 classes
Hi all, this is my first post in R devel? sorry if I lost some of the guidelines.
Anyway this is my problem:
Version:
R version 2.15.2 (2012-10-26)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
I want to make an S4 class that use the output object of the function of nls.lm as a slot:
setOldClass("nls.lm")
setClass (
Class="TestClass",
2015 Jan 24
0
Proper way to define cbind, rbind for s4 classes in package
On Sat, Jan 24, 2015 at 12:58 AM, Mario Annau <mario.annau at gmail.com> wrote:
> Hi all,
> this question has already been posted on stackoverflow, however without
> success, see also
> http://stackoverflow.com/questions/27886535/proper-way-to-use-cbind-rbind-with-s4-classes-in-package.
>
> I have written a package using S4 classes and would like to use the
> functions