similar to: Was: setValidity and "initialize" method conflict ? [in R-help]

Displaying 20 results from an estimated 2000 matches similar to: "Was: setValidity and "initialize" method conflict ? [in R-help]"

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
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
2007 Mar 31
1
Problem with S4 inheritance: unexpected re-initialization?
Dear all, To explain my problem I am attaching a demonstration package "myclasspkg": I have the following two S4 classes with similar inheritance: SubSubClassA <- SubClassB <- BaseClass SubSubClassB <- SubClassB <- BaseClass In R I am calling the following functions: > library(myclasspkg) > subA <-
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))
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
2010 Mar 08
1
setClass or setValidity?
Hi,   I'm reading up on S4 classes *). There seem to be at least two ways of input validation: setClass() (using the 'validity' argument)  and setValidity(). Is it a matter of taste which function is used? Or should more complex validation code better be put in a setValiditity call? *) A (Not So) Short Introduction to S4 Object Oriented Programming in R V0.5.1 Christophe Genolini
2008 May 07
1
optional setValidity()
Hi Suppose I have an S4 class "foo" and a validity checking function ".checkfoo()": setClass("foo", representation=representation("numeric")) setValidity("foo" , .checkfoo) is fine; in my application, .checkfoo() verifies that a bunch of necessary conditions are met. But .checkfoo() is very time consuming and I want to give users the option
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"),
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
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
2004 Jun 18
0
Problem with setValidity() or resetClass() or ... ?
Hi, I'm working with Version 1.9.0 (2004-04-12) on Windows 98/NT/2000 where I found the following wrong (?) behavior of setValidity(). I already mentioned this on the R-help list (2004-06-11, was "setValidity changes Extends?") , but as I got no answer I tried to figure out what's happening. Well, setValidity() behaves not as I would expect (something about the
2003 Sep 27
2
does isGeneric work differently in 1.8.0 ?
Hello, the last command (isGeneric) in following R-code (attached) produces different output, depending on wheter 1.8.0 alpha or 1.7.1 is used. Is that to be expected ? Both R Versions were started with option vanilla --------------------------------------------------- R.1.7.1: --------------------------------------------------- > version _ platform i686-pc-linux-gnu arch i686
2004 Jan 29
2
Object validation and formal classes
I'm using R 1.8.1 (Win32, Linux) and have some difficulties using validation functions for S4 classes. The problem is if I specify a validation function with setValidity("myclass", validate.myclass) object validation is only performed when I create an instance using new("myclass"), or when I explicitly call validObject(x) where x is of class "myclass", of
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
2009 Mar 20
1
classes and methods
I have put together a test class and methods > setClass("foo",representation(x="numeric")) [1] "foo" > setMethod("plot","foo",function(x,y,...)boxplot(x,...)) [1] "plot" > x <- rnorm(100) > class(x) <- "foo" > plot(x) > y <- new("foo",x=rnorm(50)) > class(y) [1] "foo" My
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
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
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
2007 Apr 19
2
setClass inside a function
Hello, I would like to create a function that gets passed a class name and then calls setClass, and a few other functions, inside. I have done this in the past with setmethod, creating accessors for all slots in a set of S4 classes. But setClass is choking when my function is called isnide a package, telling about an error in exists(cname, where). I assume this to be a problem with the
2005 Oct 22
0
after package reorganization: version 1.6 of package "distr" available; new packages "distrEx", "distrSim", "distrTEst", "RandVar"
After some reorganization, we would like to announce the availability on CRAN of a new version (1.6) of our package "distr" as well as the availabilty on CRAN of the new packages "distrEx", "distrSim", "distrTEst", "RandVar". ----------------------------------------------------------------------------------------- Changes from 1.5 to 1.6 -[former