Displaying 20 results from an estimated 20000 matches similar to: "S4 generating function"
2009 Jun 05
2
S4: When is validObject issued? (or why S4 is killing me:( ..
Dear UseRs,
Does anyone know when exactly the validity is checked in S4? Documentation is silent:(.
Here is a small example:
setClass("test1",representation(a="numeric"))
setMethod("initialize","test1",
function(.Object,...){
a<-runif(1) ## here slot "a" is initialized ##
callNextMethod(.Object,a=a,...)
2009 Jun 05
1
S4: Initialization method called during setClass??
Dear UseRs,
A simple class inheritance example:
> setClass("test",representation(a="numeric"))
> setMethod("initialize","test",
function(.Object,x,...){
print("Initialization!!!")
callNextMethod(.Object,a=x,...)
})
> new("test",x=23)
[1] "Initialization!!!"
An
2006 Apr 12
1
yet another problem with S4 dispatch (with setClassUnion)
Dear John and Seth, dear R-devels,
once again the question of method dispatch in S4 -- this time with
setClassUnion(); taking up your advice in
https://stat.ethz.ch/pipermail/r-devel/2006-April/037200.html
https://stat.ethz.ch/pipermail/r-devel/2006-April/037201.html
I have been too quick in stating that
>setClassUnion()---at least in my case---solves the problem;
>
The problem arises
2010 Feb 02
1
S4 setClass / initialize misunderstanding
Hi, I recently ran into this problem. I couldn't find any mention of it in
the setClass documentation.
setClass("Foo", representation(file = "character"))
setMethod("initialize", "Foo", function(.Object, file) {
print(file)
})
setClass("Bar", contains = "Foo")
And the error:
Error in print(file) : argument "file" is
2006 May 11
2
S4 initialize methods, unexpected recursive callNextMethod
Hi,
Given a simple three class hierarchy: A <-- B <-- C
I want to define an initialize method for each class such that when I
call new("C", x=5), the initialize methods for A and B are used to
incrementally build the object.
When I do what seems obvious to me using callNextMethod, I get an
infinite recursion. An example follows...
setClass("A",
2014 Feb 11
1
getting environment from "top" promise
Hi all,
It seems that there is a use case for obtaining the environment for the
"top" promise. By "top", I mean following the promise chain up the call
stack until hitting a non-promise.
S4 data containers often mimic the API of base R data structures. This
means writing S4 methods for functions that quote their arguments, like
with() and subset(). The methods package
2006 Apr 07
4
setIs and method dispatch in S4 classes
Dear all,
I have a question regarding setIs and method dispatch in S4 classes:
Consider the following example:
#####################################################
## A02 "contains" A01 by setIs:
setClass("A01", representation(a="numeric",b="numeric"))
setClass("A02", representation(a="numeric",d="numeric"))
2010 Oct 04
2
Recursion error after upgrade to R_2.11.1 [Sec=Unclassified]
Hi all,
After an upgrade from R_2.10.1 to R_2.11.1 I am now getting the following error:
Error: evaluation nested too deeply: infinite recursion / options(expressions=)?
This occurs in the initialize method of S4 classes where I was initialising attributes eg:
.Object[['realtimeState']] <- list()
I can avoid this new error by altering the code to do:
.Object$realtimeState <-
2013 Feb 05
1
S4 Classes and Initialize methods
Hello,
I am trying to improve my skill on S4 classes. But there's something
strange (to me) happening with "initialize" methods. This is probably a
normal behaviour... but... something is unclear in my mind
I declare two classes, namely "A", and "B", which has a slot of type A. The
class "A" has an initialize method. What I do not understand is that
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
2009 Jul 09
1
How to: initialize, setValidity, copy-constructor
Hello list,
I'm having troubles setting up a basic calss hierarchy with S4.
Here is a simplified schema of what I'd like to do:
- Two classes: A and B that extends A
- Ensure that the slots added by B are consistent with the slots of A
- Let A initialize itself (I'm not supposed to know the internal cooking
of A)
- By default set the slots of B based on the slots that A initialized
2009 Jan 25
3
Defining an iterator
Inspired by Rudolf Biczok's query of Fri, Jan 23, 2009 at 1:25 AM, I
tried to implement iteration in a generic way using S4. (Though I am
admittedly still struggling with learning S4.)
> setClass("foo",representation(bar="list"))
[1] "foo"
> x<-new("foo",bar=list(1,2,3))
Given this, I would not expect for(i in x)... to work, since R has no
way
2011 Mar 11
1
WARNING Undocumented S4 methods 'initialize' - why?
Dear all,
I am just writing the documentation file for S4 class 'QualTreeSet' and
get the following warning with R CMD check:
* checking for missing documentation entries ... WARNING
Undocumented S4 methods:
generic 'initialize' and siglist 'QualTreeSet'
All user-level objects in a package (including S4 classes and methods)
should have documentation entries.
See the
2010 Sep 23
1
strange behaviour of callNextMethod in S4 methods
Hello,
I experienced a strange behaviour of callNextMethod when used in either
initialize or any other S4 function method definition.
Help says callNextMethod calls the next inherited method for the current
function from where it is called with the same actual (non missing)
arguments. This is OK. The problem appears when some formal arguments
(in particular, S4 objects) of this function are
2006 Sep 08
2
Extending [ method to S4 class and drop argument (PR#9211)
Full_Name: John Verzani
Version: 2.4.0 alpha (2006-09-05 r39134)
OS: linux, gentoo 2.6.17
Submission from: (NULL) (163.238.43.26)
When extending the "[" method to a new S4 class, the default value for the drop
argument is not being found. Here is a small example:
setClass("test",representation(x="character"))
2013 Mar 01
1
S4-classes: Assignment of values to slots by reference
Dear R-users,
I am working on a project that uses S4-classes. At some point I encountered the problem - well known to R - that I have to pass 3 different objects to a function, that should modify several slots of them and of course there is no passing by reference in R.
Then I read this thread by Steve Lianoglou: https://stat.ethz.ch/pipermail/r-help/2010-August/250468.html, which offers from
2003 May 21
1
callNextMethod
Hi,
I don't understand why this code doesn't work (f(b2)):
/////////////////
setClass("B0", representation(b0 = "numeric"))
setClass("B1", representation("B0", b1 = "character"))
setClass("B2", representation("B1", b2 = "logical"))
f <- function(x) class(x)
setMethod("f", "B0",
2005 Jan 07
1
S4 class no longer accepts matrix in array slot under 2.0.1
I have an S4 class with a slot of class "array", and in upgrading to 2.0.1
(from 1.9.1) I have encountered a change in behaviour. This causes me some
difficulties if I want to allow 2-dimensional arrays in the slot.
The following (in 2.0.1) illustrates the point:
> setClass("foo",representation("array"))
[1] "foo"
> a <-
2012 Nov 06
2
Question on callNextMethod
I don't understand why I get the following results. I define two classes
'Base' and 'Derived', the latter of which 'contains' the first. I then
define a generic method 'test' and overload it for each of these classes. I
call 'callNextMethod()' in the overload for Derived. From the output, it
appears that the overload for Base gets called twice. Why is
2005 Jan 09
1
S4 class no longer accepts matrix in array slot under 2.0.1
I have an S4 class with a slot of class "array", and in upgrading to 2.0.1
(from 1.9.1) I have encountered a change in behaviour. This causes me some
difficulties if I want to allow 2-dimensional arrays in the slot.
The following (in 2.0.1) illustrates the point:
> setClass("foo",representation("array"))
[1] "foo"
> a <-