similar to: Validity check when setting slot

Displaying 20 results from an estimated 8000 matches similar to: "Validity check when setting slot"

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
2011 Mar 04
1
Extending type list: names and inherited methods issue
Hi, I want to extend the type list, but it looks like the names are not handled properly (in the show method), not the [ method. See below for code example. I imagine this comes from the S3/S4 mixing, but I would like to understand and the recommended work around (that avoid redefining all the list methods [, $, etc...). Thank you. Bests, Renaud # define S4 class that inherits from list
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 Sep 15
2
S3 objects in S4 slots
Hello, I am the maintainer of the stringkernels package and have come across a problem with using S3 objects in my S4 classes. Specifically, I have an S4 class with a slot that takes a text corpus as a list of character vectors. tm (version 0.5) saves corpora as lists with a class attribute of c("VCorpus", "Corpus", "list"). I don't actually need the
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 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"),
2010 May 06
1
Validity glitch when contains="matrix"
Sirs: My validity function did not run when my class contains="matrix". But if I first define the class with contains="numeric", then define it again with contains="matrix", validity runs. Here's the session: > f <- function(object) "BAD CLASS" # force error to > setClass("A", contains="matrix", validity=f) [1]
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") +
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
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))
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 =
2011 Oct 05
1
Behaviour of 'source' with URLs and proxy
Hi, I am having troubles sourcing a file from our local network from R. It looks like this file are not properly accessed by 'source', even they can be downloaded with download.file. (See below my settings and some tests I did). I ended up with a work around, but I would like to understand what is going on. Doesn't source/readLines uses the same mechanism as download.file to
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
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"))
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
2004 May 27
3
"privileged slots"
Hi all, in the help for RClassUtils I found the expression "privileged slots" in function "checkSlotAssignment" with the explanation: /privileged slots (those that can only be set by accesor functions defined along with the class itself)/ I thought all slots of a (not private) class can be a accessed by a user via the @ Operator. Is there a way to make a single slot of a
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")
2008 Jun 07
1
slot(obj, "nosuch") documentation question
Using slot() on object (or "@") and using a nonexistent slotname returns an error (see example code). R> setClass("foobar", representation=list(a="numeric")) [1] "foobar" R> foobar <- new("foobar", a=5) R> foobar at a [1] 5 R> foobar at b Error: no slot of name "b" for this object of class "foobar" The details
2005 Mar 22
2
can R_do_slot_assign change slot type
Hi, It seems that R_do_slot_assign can change the type of an S4 class slot. For example I have a class setClass("ostream", representation(id = "integer", keepOpen = "logical")) and inside a C-function I was able to assign a RAW vector to the id slot. Is this intentional? I remember reading somewhere that the slot type is guaranteed by R. Maybe this doesn't
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