[R] Extending a data frame with S4

Matthias Kohl Matthias.Kohl at stamats.de
Tue Jan 3 12:36:06 CET 2006


the help page on "setOldClass" might help you. In particular the section 
"Register or Convert?".

Matthias

hadley wickham schrieb:

>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 at 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
>  
>


-- 
StaMatS - Statistik + Mathematik Service
Dipl.Math.(Univ.) Matthias Kohl
www.stamats.de




More information about the R-help mailing list