[R] Extending a data frame with S4

From: hadley wickham <h.wickham_at_gmail.com>
Date: Tue 03 Jan 2006 - 20:45:28 EST


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



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Tue Jan 03 20:50:44 2006

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:41:45 EST