Hi,

Is it intended to support assignment of a derived instance (S3) to a parent container 
(S4)?

setClass("any")
setClass("myclass",representation(x="any",y="any")) # I define parent containers x,y

#I have an S3 object.
xx<-3
class(x)

#instantiate a new object of class myclass
tt<-new("myclass")
[EMAIL PROTECTED]<-xx   #not allowed as expected.

# I want to assign xx anyway.  This should be possible if xx inherits class "any".  
This can be easily achieved by ?class.
class(xx)<-c(class(xx),"any")
class(xx) #now it is of class "any"

[EMAIL PROTECTED] <- xx #but it still can not be assigned to the parent container.


#The same works for 'pure' S4 classes.
setClass("Numeric",contains="any")
xx<-new("Numeric")
is(xx)


[EMAIL PROTECTED]<-xx #works.

Is it intended to support S3 class inheritance within S4? It would be great because 
most of the objects in R are still S3.

Yours 
/E

______________________________________________
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to