Re: [Rd] How to put my S4 class into data.frame

From: John Chambers <jmc_at_r-project.org>
Date: Sat 04 Nov 2006 - 14:22:11 GMT

Designing a "better data frame" is something many people have likely thought about; I certainly have.

But data frames are so widely used and so central to models and other software that a major change needs to be done by the user community, or at least with maximum feedback, IMO.

Also, my prior feeling would be that it's better to think of an S4 class to play the role of data.frame, rather than tinkering with the S3 class to allow S4 columns. Having formal classes (particularly using class unions to abstract notions about variables in the data frame) lets one create a more precise and reliable definition.

It's true, though, that one then has to work out the details of interfacing the S4 data frame class to current software that works with the S3 data.frame class. AFAICS that is not too hard, but of course the details would be important.

I've played around with some of these ideas, more as educational aids in discussing classes and methods than as a serious proposal. Last time I looked, the writeup was not at a level I would feel happy circulating :-} But perhaps a group of interested people could exchange some ideas.

Gregor Gorjanc wrote:
> Hi,
>
> Martin Maechler wrote:
>
>>>>>>> "Gregor" == Gregor Gorjanc <gregor.gorjanc@bfro.uni-lj.si>
>>>>>>> on Sat, 04 Nov 2006 02:09:13 +0100 writes:
>>>>>>>
>> Gregor> Ferdinand Alimadhi wrote:
>>
>> >> tmp$comp <- x@ratios ?!
>>
>> Gregor> I "lose" class here and that is not what I
>> Gregor> want. Perhaps I should stick with list instead of
>> Gregor> data.frame.
>>
>> Yes, I probably would, at least for the time being.
>>
>
> OK. Why do you say "at least for the time being"? Are there any plans to
> generalize putting S4 classes that are not atomic into data.frame?
>
>
>> OTOH, it's interesting that some methods to "stick some S4
>> objects into a data frame do work fine , at least for the
>> following case (R-script below) -- and I wonder if we (R developers)
>> shouldn't think about more explicitly supporting this,
>> e.g., by stating something like
>>
>> >> If an S4 object simply *contains* an atomic class that can be
>> >> used as data.frame column, then that S4 object can also be used
>> >> as data.frame column
>>
>>
>
> Gregor
>
> ______________________________________________
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>

        [[alternative HTML version deleted]]



R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Sun Nov 05 03:17:47 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sat 04 Nov 2006 - 17:30:34 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.