Skip to content
Prev 13839 / 63421 Next

Problem with _new_ if class "lm" in object representatio n.

Hi,

For your lm problem, you could begin to create a virtual class that accepts 
either NULL or a lm object:

 > setClassUnion("mylm", c("NULL","lm"))
 > setClass("foo", representation(x="numeric", y="mylm"))
 > new("foo",x=1,y=NULL)

Then, you have to check the content of slot y in any function that will 
manipulate objects of class "foo":


         setMethod("show","foo",function(object)
         {
         cat("\n object of class foo")
         if (!is.null(object@y)) cat(" does have a lm object in slot y!")
         })


Eric
At 14:35 30/09/2004, Witold Eryk Wolski wrote:
Eric Lecoutre
UCL /  Institut de Statistique
Voie du Roman Pays, 20
1348 Louvain-la-Neuve
Belgium

tel: (+32)(0)10473050
lecoutre@stat.ucl.ac.be
http://www.stat.ucl.ac.be/ISpersonnel/lecoutre

If the statistics are boring, then you've got the wrong numbers. -Edward 
Tufte