Skip to content
Prev 26986 / 63461 Next

S4 class extending data.frame?

I had the same problem. Generally data.frame's behave like lists, but
while you can extend list, there are problems extending a data.frame
class. This comes down to the internal representation of the object I
guess. Vectors, including list, contain their information in a (hidden)
slot .Data (see the example below). data.frame's do not seem to follow
this convention.

Any idea how to go around?

The following example is exactly the same as Ben's for a data.frame, but
using a list. It works fine and one can see that the list structure is
stored in .Data

* ~: R
R version 2.6.1 (2007-11-26)
[1] "c3"
An object of class ?c3?
[[1]]
[1] 1 2 3

[[2]]
[1] 2 3 4

Slot "comment":
[1] "hello"
[[1]]
[1] 1 2 3

[[2]]
[1] 2 3 4

Regards,
Oleg
On Thu, 2007-12-13 at 00:04 -0500, Ben Bolker wrote: