Thanks for your reply.
Experimenting a little further, I was able to learn a bit more and find what is
the real problem of mine what the real question is.
I could create my S4 extended class by adding these two lines in my namespace
file
importClassesFrom(Matrix,Matrix)
importClassesFrom(Matrix,dMatrix)
and then creating my new class in another R file
library(Matrix)
setClass("myMatClass",
representation("dMatrix",myslot="numeric"))
which creates the new S4 class when my package is loaded.
The problem is that I would like to create the class inside a function of mine:
createMyS4Class() {
library(Matrix)
setClass("myMatClass",
representation("dMatrix",myslot="numeric"))
}
so that, at some point (after my package is loaded ), I can do something like:
if (cond)
createMyS4Class()
Now, I understand that at this point, my package environment is locked. So the
question become:
Is there any way that I can unlock my package environment, create my new S4
class and lock it back or something?
Please let me know if that makes sense ?
I appreciate your comments.
-importing the foreign S4 class in my namespace file
----- Original Message ----
From: Seth Falcon <sfalcon@fhcrc.org>
To: johan Faux <johanfaux@yahoo.com>
Cc: r-help@stat.math.ethz.ch
Sent: Monday, June 4, 2007 2:40:21 PM
Subject: Re: [R] locked environment and inheritance
johan Faux <johanfaux@yahoo.com> writes:
> Hi,
>
> I have a S3 package with namespace called "myS3Pkg". Inside my
package
> I would like to create a S4 class which extends (adds 2 slots) another
> S4 class from some other package. The class should be created in
> "myPkg" environment (and not global environment).
>
> Using:
>
>
> setClass("myS4class", representation("otherS4class",
mydata > "numeric"), where = topenv())
have you tried just omitting the where argument? Classes will get
defined in the package environment and I think that's what you want.
+ seth
--
Seth Falcon | Computational Biology | Fred Hutchinson Cancer Research Center
http://bioconductor.org
____________________________________________________________________________________
[[alternative HTML version deleted]]