Displaying 20 results from an estimated 10000 matches similar to: "S4: When is validObject issued? (or why S4 is killing me:( .."
2005 Aug 05
1
S4 generating function
Can someone explain what the problem is when I use the
generating function? And how to get debug() to stop in
the Superclass initialize method?
---- source -----
setClass("Superclass",
representation(id = "character"),
contains = "VIRTUAL")
setMethod("initialize",
signature(.Object = "Superclass"),
2007 Mar 04
1
Problem using callNextMethod() in S4
Dear all,
Maybe, I am doing something wrong, but using R-2.5.0 on my Intel-Mac, I
have problems
using function callNextMethod() in method initialize.
I am loading the following code as file "testS4.R":
setClass("baseClass",
representation(myname = "character",
mydir = "character",
"VIRTUAL"),
2008 Feb 29
1
Problems initializing an extended S4 class
Hi all,
I am having trouble extending S4 classes in cases where I'm using both
validity and initialize methods. I've read as much S4 information as I
can find, but I've yet to have that "a-ha" moment.
In my application, I am using validity methods to guard against
inappropriate input data that my code has no way of handling, and
initialize methods to detect and deal
2007 Jul 25
2
initalizing and checking validity of S4 classes
Dear useRs and wizaRds,
I am currently developing a set of functions using S4 classes. On the way I encountered the problem exemplified with the code below. For some reason the 'validity' method does not seem to work, i.e. does not check for errors in the specification of the slots of the defined class. Any hints?
My understanding of the whole S4 system was that validity checks are made
2009 Oct 26
1
Why 'validity' is not called? (S4)
I thought that 'validity' defined in 'setClass' should be called in
'new'. Could somebody let me know why 'validity' is not called? How to
make it be called?
> setClass(
+ Class='A',
+ representation=representation(
+ x='numeric'
+ ),
+ validity=function(object){
+ cat("~~~ A: inspector ~~~\n")
+
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
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
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",
2007 Dec 23
1
Problem with initialize of S4 classes
Dear all
Below is the code for "scriptPreFilter.R" which gives the following result:
> source("scriptPreFilter.R")
> prefltr <- new("PreFilter", mad=c(0.5,0.01))
[1] "------initialize:PreFilter------"
[1] "------initialize:Filter------"
> str(prefltr)
Formal class 'PreFilter' [package ".GlobalEnv"] with 2 slots
2008 Feb 08
2
learning S4
Hi the list.
I try to learn the S4 programming. I find the wiki and several doc. But
I still have few questions...
1. To define 'representation', we can use two syntax :
- representation=list(temps = 'numeric',traj = 'matrix')
- representation(temps = 'numeric',traj = 'matrix')
Is there any difference ?
2. 'validityMethod' check the
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
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 <-
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
2003 Nov 19
2
Was: setValidity and "initialize" method conflict ? [in R-help]
Hello,
Thomas Stabla (statho3@web.de) has already sent this
question to R-help, Wed, 12 Nov 2003 21:21:31 +0100,
but we are not sure whether we should better post this
mail to this audience than to R-help:
---------------------------------------------------------------------
We are using S4-classes and want to force a validity check
when an object is created.
How can this be done, when an
2003 Mar 17
1
What does is() mean?
Suppose you have a class, say sex, for lack of a better example, and
you are tempted, in defining the behavior of the call,
is(x,"sex")
to check whether certain basic features are satisfied, not to just trust the claim
that x is specified to be of class "sex". `Without delving into details
further sanity checking of the structure of the object is sometimes prudent to
avoid
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
2012 Aug 03
1
Interaction between callNextMethod() and selectMethod()
Hi,
Strange things happen. Here is a simple example:
> setClass("A", contains="integer")
> setMethod("as.matrix", "A", function(x, ...) t(callNextMethod()))
Creating a generic function for ?as.matrix? from package ?base? in
the global environment
[1] "as.matrix"
> a <- new("A", 1:3)
> as.matrix(a)
2010 Jul 20
1
Extract callNextMethod "array" calls "matrix"?
I have a class that extends array and my method for "[" stops with an error:
> setClass("A", contains="array")
[1] "A"
> setMethod("[", "A", function(x, i, j, ..., drop = TRUE) new("A",
callNextMethod()))
[1] "["
> a<-new("A",array(1:12,c(4,3,1)))
> a
An object of class "A"
, , 1
2008 Sep 09
1
building a package that contains S4 classes and methods
Hello R users,
I am trying to make a my first package and I get an error that I can
understand. The package is build out of three files (one for functions, 1
for s4 classes and 1 for s4 methods).
Once I source them I run
package.skeleton( name="TDC" )
within a R session and I get
Creating directories ...
Creating DESCRIPTION ...
Creating Read-and-delete-me ...
Saving functions and
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",