[R] Extending a data frame with S4

hadley wickham h.wickham at gmail.com
Tue Jan 3 10:45:28 CET 2006


I'm trying to create an extension to data.frame with more complex row
and column names, and have run into some problems:

> setClass("new-data.frame", representation("data.frame"))
[1] "new-data.frame"
Warning message:
old-style ('S3') class "data.frame" supplied as a superclass of
"new-data.frame", but no automatic conversion will be peformed for S3
classes in: .validDataPartClass(clDef, name)

Do I need to be worried about this?

> new("new-data.frame", data.frame())
Error in initialize(value, ...) : initialize method returned an object
of class "data.frame" instead of the required class "new-data.frame"

I guess this is related to the warning above.  I presume I can fix
this with an initialize function, but I'm not sure how to go about
referring to the data frame that is the object.
Is there a way to extend a data.frame, or do I need to create an
object that contains the data frame in a slot?

Thanks for your help,

Hadley




More information about the R-help mailing list