Displaying 20 results from an estimated 10000 matches similar to: "Validity glitch when contains="matrix""
2006 Mar 06
1
validObject does not check validity of slots
The documentation for validObject suggests that slots are checked for
validity, but validObject seems only to check that the slot has
something claiming to be correct; validObject(obj) does not perform
the equivalent of validObject(obj at y) for slot y.
This is also the second problem issue reported in
http://tolstoy.newcastle.edu.au/R/devel/05/03/0151.html
Relevant documentation, an example,
2009 Aug 17
2
S4: inheritance of validity methods?
Dear Developers,
In current implementation of validity method, objects are first coerced to  
superclass (slots are striped). Thus, it is not possible to write validity  
method which would perform some checks on children slots.
Say, I want to check if number of slots in a class is equal to "n":
setClass("A", representation(a="numeric", n="integer"),
    
2008 Apr 15
1
Pb with validObject(..., complete=TRUE)
Hi,
When called with complete=TRUE, validObject() is supposed to work in a
recursive manner. But here is a situation where it doesn't seem to be
the case.
Let's define a class with a validity method:
   setClass("PosInts", representation(ii="integer"))
   setValidity("PosInts",
     function(object)
     {
       if (!all(object at ii > 0))
        
2019 Aug 19
1
class() bug when used within a validity method
Hi,
This is a long-standing bug where 'class(object)' does not
return the actual class of 'object' when used inside a validity
method. Instead it seems to return the class for which the validity
method is defined. For example:
   setClass("A", slots=c(stuff="ANY"))
   setValidity("A", function(object) {
     cat("validating an object of
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")
+      
2015 May 28
3
S4 inheritance and old class
Hey everyone,
I would like to develop a package using S4 classes.
I have to define several S4 classes that inherits from each others as
follow:
# A <- B <- C <- D
I also would like to define .DollarNames methods for these class so, if I
have understood well, I also have to define an old class as follow:
# AOld <- A <- B <- C <- D
setOldClass(Classes = "AOld")
2003 Aug 24
2
setClass question
I would like to add a class to the SparseM package.  I have a class "matrix.csr"
that describes a matrix in compressed sparse row format, now I would like a class
matrix.diag.csr that describes such objects when they happen to be diagonal.
The idea is that matrix.diag.csr objects should behave (later in life) exactly like
matrix.csr objects, the distinction is only needed in order to
2009 Aug 10
1
Validity check when setting slot
Hi,
I'm wondering if the following behaviour is normal:
setClass('A', representation(number='numeric'), 
validity=function(object){ 
if( object at number < -1 ) return("Invalid number"); TRUE})
>[1] "A"
a <- new('A')
a
>An object of class ?A?
>Slot "number":
>numeric(0)
a at number <- 0
a at number <- -3
a
>An
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
2008 Apr 09
1
coerce methods and inheritance
Hi,
It doesn't seem that the dispatching algo is finding my coerce method under
some circumstances.
Let's say I have 2 classes, A and AA and that AA is just a direct extension
of A with no additional slots:
   setClass("A", representation(ii="integer"))
   setClass("AA", contains="A")
I can define a method for coercing my objects to an integer
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
2011 Jan 28
2
help with S4 objects: trying to use a "link-glm" as a class in an object definition
Hi,
I'm trying to make a new S4 object with a slot for a "link-glm" object. R doesn't like me have a slot of class "link-glm"
> class(make.link("probit"))
[1] "link-glm"
> setClass("a",representation(item="link-glm"))
[1] "a"
Warning message:
undefined slot classes in definition of "a": item(class
2009 Jun 18
1
validObject throws non-caught error when slot doesn't exist
I have been retooling an S4 class definition to include another slot and 
have found that the methods::validObject function (defined in 
methods/R/SClasses.R) in R-devel throws an error that isn't caught 
internally (and thus not controllable by 'test' argument) when 
retrieving a non-existent slot. The offending line of code is shown below:
 > validObject
function (object, test =
2015 May 12
2
Unexpected failure when calling new() with unnamed arg and
Hi,
The man page for new() suggests that if 'a' is an object with slots
"slot1" and "slot2" and C is a class that extends the class of 'a',
then the 2 following calls should be equivalent:
   new("C", a, ...)
   new("C", slot1=a at slot1, slot2=a at slot2, ...)
This is generally the case but I just ran into a situation where it's
not.
2015 May 13
2
Unexpected failure when calling new() with unnamed arg and
Thanks Martin for looking into this.  H.
On 05/13/2015 03:57 AM, Martin Maechler wrote:
>>>>>> Herv? Pag?s <hpages at fredhutch.org>
>>>>>>      on Tue, 12 May 2015 15:18:42 -0700 writes:
>
>> Hi,
>
>> The man page for new() suggests that if 'a' is an object with slots
>> "slot1" and "slot2" and C is a
2013 Jan 13
2
Regarding the recent changes to @<-
Hello all,
  In one of the packages (phylobase) I'm contributing to, we define a class
as follows:
setClass("phylo4",
         representation(edge = "matrix",
                        edge.length = "numeric",
                        label = "character",
                        edge.label = "character",
                        order =
2006 Sep 21
1
validity testing as part of '@<-'
'methods' package feature request / discussion starter:
perhaps a call to 'validObject' should occur at part of any slot  
replacement operation (and the operation not be carried out if it  
would invalidate the object)?  this may prevent the need for  
prophylactic 'validObject' calls in other user-defined functions.  in  
the example below, the slot assignment occurs
2015 Oct 08
1
Unexpected failure when calling new() with unnamed arg and
>>>>> Joshua Wiley <jwiley.psych at gmail.com>
>>>>>     on Thu, 8 Oct 2015 12:19:16 +1100 writes:
    > Hi, I realize this is an old thread, but just wondering
    > whether a conclusion was ever reached on this issue?  I'm
    > using formula(NULL) but it would be nice if default
    > initialization worked for formula classes as well.
Well,
2006 Jan 19
2
creating objects with a slot of class formula, using new
Hi, 
 
This works fine.
>setClass("a",representation(b="list",c="list"))
>new("a",b=list(7))
>An object of class "a"
Slot "b":
[[1]]
[1] 7
 
Slot "c":
list()
 
But, now suppose you want a slot to accept an object of class formula...
>setClass("a",representation(b="list",c="formula"))
2005 Aug 03
0
A question on validity checking for S4 classes
Folks:
(This is a question on the formal S4 class system). R 2.1.1 on Windows.
I'm pretty sure the following is a failure of my understanding, rather than
a bug, so may I ask for some clarification?
The Green book states that (p. 295) "Objects are checked for validity when
permanently assigned, or explicitly by the function validObject()." The Help
for setValidity() seems silent