search for: validobject

Displaying 20 results from an estimated 105 matches for "validobject".

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.ed...
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)...
2005 Mar 18
0
2 possible bugs in function validObject (PR#7735)
Hi, > R.version.string [1] "R version 2.0.1, 2004-11-15" I have found two possible bugs in function validObject. Details below. Cheers, Scott ================================== Scott D. Chasalow Principal Statistician Statistical Genetics and Biomarkers Bristol-Myers Squibb Company Email: scott.chasalow <AT> bms.com ================================== ------ BEGIN R commands and output ------ setCla...
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 = FALSE, complet...
2011 Nov 28
0
extend validObject to validate any object (shallow and deep validation)
Hi, It would be nice if there was a tool for checking the validity of any object. validObject() is of course the natural candidate for this but right now it doesn't work on S3 objects: df <- data.frame(aa=1:4, bb=letters[4:1]) attributes(df)$row.names <- c("A", "B", "C", "A") 'df' is an invalid data frame instance: > d...
2019 Jan 24
0
Possible setClassUnion Unloading Issue
...LL", c("character", "NULL"))' writeLines(code, file.path(testpkg, 'R', 'union.R')) install.packages(testpkg, repos=NULL, type='src') ## Load the package and check validity of a character object library('testpkg') validObject('hello') ## [1] TRUE ## Detach, unload, and confirm that superclass is still attached ## to character detach('package:testpkg', unload=TRUE) getClassDef('character') ## Class "character" [package "methods"] ## ## N...
2005 Jun 06
2
Bug in new() or validObject() in methods package (PR#7922)
Something in new() or validObject() in the methods package is messing up. This happens in both 2.1.0 and R-devel in Windows. I'd like to have an empty expression for a slot in a class. An empty expression is an expression: > is.expression(expression()) [1] TRUE > > is(expression(), "expression") [1]...
2008 Dec 17
1
glmnet : Error in validObject(.Object) :
Could any one help ? I start to learn the glmnet package. I tried with the example in the manual. x=matrix(rnorm(100*20),100,20) y=rnorm(100) fit1=glmnet(x,y) When I tried to fit the model, I received the error message: Error in validObject(.Object) : invalid class "dgCMatrix" object: row indices are not sorted within columns Thank you very much!
2012 Oct 11
1
as.data.frame.matrix() returns an invalid object
...> attributes(df1) $names [1] "a" "b" $row.names integer(0) $class [1] "data.frame" > attributes(df2) $names [1] "a" "b" $class [1] "data.frame" Actually 'df2' is considered broken by validObject(): > validObject(df1) [1] TRUE > validObject(df2) Error in validObject(df2) : invalid class ?data.frame? object: slots in class definition but not in object: "row.names" This is with R 2.15 and recent R devel. Cheers, H. -- Herv? Pag?s Program in Computation...
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 ev...
2003 Aug 24
2
setClass question
...nsion=as.integer(c(3,3))) An object of class "matrix.csr" Slot "ra": [1] 1 2 3 Slot "ja": [1] 1 2 3 Slot "ia": [1] 1 2 3 4 Slot "dimension": [1] 3 3 > new("matrix.diag.csr",ra=1:3,ja=1:3,ia=1:4,dimension=as.integer(c(3,3))) Error in validObject(.Object) : Invalid "matrix.csr" object: invalid dimension attribute the traceback() says: 16: stop(paste("Invalid \"", Class, "\" object: ", errors, sep = "")) 15: validObject(.Object) 14: .local(.Object, ...) 13: initialize(value, ...) 12: initia...
2010 May 06
1
Validity glitch when contains="matrix"
...alidity=f) [1] "A" > new("A",as.matrix(1)) # should generate a validity error, does not An object of class “A” [,1] [1,] 1 > setClass("B", contains="numeric", validity=f) [1] "B" > new("B",1) # generates the error Error in validObject(.Object) : invalid class "B" object: BAD CLASS > setClass("B", contains="matrix", validity=f) [1] "B" > new("B",as.matrix(1)) # generates the error Error in validObject(.Object) : invalid class "B" object: BAD CLASS On the other han...
2005 Aug 03
0
A question on validity checking for S4 classes
...mal 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 on the details, however, and this does not appear to be the R implementation. Here's an example to show why I think not: > setClass('posNumber','numeric') [1] "posNumber" > setValidity('posNumber',functio...
2003 Nov 19
2
Was: setValidity and "initialize" method conflict ? [in R-help]
...rn("warning: negative value for woo")} >setValidity("Foo", validFooObject) [1] "Foo" >new("Foo", woo = 1) # all is fine An object of class "Foo" Slot "woo": [1] 1 >new("Foo", woo = -1) # ok, negative value Error in validObject(.Object) : Invalid "Foo" object: warning: negative value for woo ------------------------------------------------------------------------- Now, if i define a initialize method for Foo, things change (R had been restarted) ----------------------------------------------------------------...
2009 Aug 17
2
S4: inheritance of validity methods?
...mes(object))!=object at n+1) paste("Number of slots must be ", object at n) else TRUE }) setClass("B", representation(b="numeric"), contains="A", prototype=list(a=12, b=14, n=2L)) new("B", a=11, b=33) Error in validObject(.Object) : invalid class "B" object: Number of slots must be 2 Error, because an object of class "A" is passed to validObject with one slot "b" removed and n=2. Is were a work around for this, or I am just doomed to write the same validity method for each chi...
2011 Jan 28
2
help with S4 objects: trying to use a "link-glm" as a class in an object definition
...Class("a",representation(item="link-glm")) [1] "a" Warning message: undefined slot classes in definition of "a": item(class "link-glm") > fa <- function() { + new("a",item=make.link("probit")) + }> > fa() Error in validObject(.Object) : invalid class "a" object: undefined class for slot "item" ("link-glm") # and a link-glm looks like a list to me, so I thought I would tell R it is a list and see what happens > setClass("b",representation(item="list")) [1] "b...
2020 Oct 30
2
Change to I() in R 4.1
...s of an S4 object > to something invalid. > > I really don't think people should be allowed to use I() to > change a valid S4 object into an invalid one, but this is what > happens (R 4.0.3 patched) : > >> require(Matrix); M <- Matrix(0, 2,3); IM <- I(M) >> validObject(IM) > Error in .classEnv(classDef) : > trying to get slot "package" from an object of a basic class ("NULL") with no slots >> IM > ----------- FAILURE REPORT -------------- > --- failure: length > 1 in coercion to logical --- > --- srcref --- &gt...
2015 May 12
2
Unexpected failure when calling new() with unnamed arg and
...t2, design=x ~ y) # works Note that new("B", a, design=x ~ y) works so the 3-level class hierarchy is really needed in order to reproduce. Probably related to this, I also noted that new("B") and/or new("C") return invalid objects: c <- new("C") validObject(c) # Error in validObject(c) : # invalid class ?C? object: invalid object for slot "design" # in class "C": got class "S4", should be or extend class "formula" is(c at design, "formula") # [1] FALSE class(c at design) # [1]...
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
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