Displaying 20 results from an estimated 10000 matches similar to: "S4 initialize or "generating function""
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
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
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
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
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 Jun 05
2
S4: When is validObject issued? (or why S4 is killing me:( ..
Dear UseRs,
Does anyone know when exactly the validity is checked in S4? Documentation is silent:(.
Here is a small example:
setClass("test1",representation(a="numeric"))
setMethod("initialize","test1",
function(.Object,...){
a<-runif(1) ## here slot "a" is initialized ##
callNextMethod(.Object,a=a,...)
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 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 <-
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
2012 Jan 10
1
Can "prototype" and "initialize" coexist?
Folks,
My object oriented background is in Java and C++. I am a novice to using S4/object-oriented coding in R but not to R. Below is an example that I found that I have expanded on.
I am not getting how "prototype" and "initialize" work together, if at all.
Here is output from a short "session"
> setClass("xx",
+
2008 Mar 20
1
setMethod for "["
Hi R-Help,
Please consider the following simple case: I have a class like
setClass("myClass",
representation(x="matrix", y="character"))
and I would like to use the method *"["* for a *myClass* objects (but
changing the default *drop* argument from TRUE to FALSE):
setMethod("[","myClass",
function(x,i,j,...,drop=FALSE)
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
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
2014 Jan 07
1
Why do methods of "initialize" have no "srcref" attribute as other S4 mehtods?
For documentation we use a system that generates Rd files from special
comments in the code. (inlinedocs).
It is crucial to be able to get the defining source code for objects like
methods to extract the comments from it.
Here is an R session that shows how this works for several kinds of methods
and (at the end of the session) how if fails for methods of "initialize"
>
2009 Jan 19
1
pass by reference for S4
Hi all;
Is it possible to modify the "@" operator that it can handle references
(or external pointers)
of S4 Object instead of the real Objects?
Or is there any technical or compatibility issue which make it
impossible?
I look forward to hear from you and also hope that you don't hate me for
my nooby question.
Yours sincerely,
Rudolf Biczok
[[alternative
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",
2013 Feb 05
1
S4 Classes and Initialize methods
Hello,
I am trying to improve my skill on S4 classes. But there's something
strange (to me) happening with "initialize" methods. This is probably a
normal behaviour... but... something is unclear in my mind
I declare two classes, namely "A", and "B", which has a slot of type A. The
class "A" has an initialize method. What I do not understand is that
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
2009 Jun 29
1
S4 and connection slot [Sec=Unclassified]
Hi all,
I am having a problem trying to declare a slot representation to hold a file connection.
With V2.8.0 I had been using:
setClass("Element",
representation(
[other slots removed],
datafileConn = setOldClass(c("file","connection"))
)
)
This resulted in a warning but still ran okay.
No however with V2.9.0 I am getting
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"),