[Rd] S4 class extends "data.frame", getDataPart sees "list"

From: Daniel Murphy <chiefmurphy_at_gmail.com>
Date: Sun, 11 Jul 2010 21:08:01 -0700


R-Devel:

When I get the data part of an S4 class that contains="data.frame", it gives me a list, even when the "data.frame" is the S4 version:

> d<-data.frame(x=1:3)
> isS4(d)

[1] FALSE                           # of course

> dS4<-new("data.frame",d)
> isS4(dS4)
[1] TRUE                            # ok

> class(dS4)
[1] "data.frame" # good
attr(,"package")
[1] "methods"
> setClass("A", representation(label="character"), contains="data.frame")
[1] "A"
> a<-new("A",dS4, label="myFrame")
> getDataPart(a)
[[1]]                                  # oh?
[1] 1 2 3

> class(a@.Data)

[1] "list"                           # hmm

> names(a)
[1] "x" # sure, that makes sense

> a

Object of class "A"
  x
1 1
2 2
3 3
Slot "label":
[1] "myFrame"

Was I wrong to have expected the "data part" of 'a' to be a "data.frame"?

Thanks.

Dan Murphy

        [[alternative HTML version deleted]]



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Mon 12 Jul 2010 - 04:13:58 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 13 Jul 2010 - 15:50:15 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.

list of date sections of archive