Skip to content
Prev 37173 / 63424 Next

S4 class extends "data.frame", getDataPart sees "list"

On 7/13/10 8:43 AM, Daniel Murphy wrote:
No, that's not the distinction.  Preferred for what, is the question. In 
order for a class to extend a basic type, it has to have that type. 
Then the .Data "slot" is a sort of fiction needed for the metadata.
(Because of some "features" of R implementation, it's not quite that 
simple.  Matrices act like a basic type, and some types, such as 
"environment" require a second kludge.)


If you really want that slot, the advice holds, but only because there 
is no actual ".Data" slot (i.e., attribute).

But you weren't talking about that at all.  In fact (just to contradict 
my previous mail) you probably wanted to turn your object into a 
data.frame.  If so, best to say so:

 > as(z, "data.frame")
Object of class "data.frame"
   x
1 1
2 2
3 3

and, for that matter:

 > as(z, "list")
[[1]]
[1] 1 2 3