Skip to content
Prev 13833 / 63421 Next

Problem with _new_ if class "lm" in object representation.

Hi,
The hint to use an lm0 instance in the protopy is a solution.

But I thought about a different solution to which I got used. This is to 
declare class "lm" as an S4 class by setClass("lm"). This is because I 
have to do it anyway quite frequently when using S3 classes, declared  
in contributed packages, in S4 classes.
Please consider the following code with this quite recent version 
generating a warning.
R : Copyright 2004, The R Foundation for Statistical Computing
Version 2.0.0 beta (2004-09-20), ISBN 3-900051-07-0

#I like to have an object which  contains an object of class fields:Krig.

library(fields)

setClass("Ctest"
        ,representation(
                test="character"
                ,bla="character"
                ,mod="Krig"
                )
        )

#Warning message: 
#Undefined slot classes in definition of "Ctest": mod (class " Krig ") in: .completeClassSlots(ClassDef, where) 

The overcome this warning i just modify the code adding

setClass("Krig")
setClass("Ctest"
        ,representation(
....

previous to defining class Ctest.
This is my working solution. But this one does not work with class "lm". 
Since,

 > setClass("lm")
Error in setClass("lm") : "lm" has a sealed class definition and cannot 
be redefined

I understand the errror message but I can't see the difference between 
class Krig and lm which are both S3 classes. (of course except that lm 
is in in THE stats package)
Is it intended to keep two different "models" of treating S3 classes? 
One for S3 class from the recomended, "base" packages and a different 
one for S3 classes from contributed packages? I assume not.
If, so I feel a alienated because my code so far rely on the behaviour 
which I observed for S3/contributed classes.


/E,
John Chambers wrote: