Skip to content
Prev 37171 / 63421 Next

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

On 7/11/10 9:08 PM, Daniel Murphy wrote:
Yes.  Also, there is a clue in the documentation for getDataPart: 
"rarely suitable to be called directly"
The data part, aka "data slot", generally does not have a class (S4 or S3).

You are probably looking for S3Part():

 > setClass("myFrame", contains = "data.frame")
[1] "myFrame"
 > z = new("myFrame", data.frame(x=1:3))
 > z
Object of class "myFrame"
   x
1 1
2 2
3 3
 > S3Part(z)
Object of class "data.frame"
   x
1 1
2 2
3 3
 > S3Part(z, strictS3 = TRUE)
   x
1 1
2 2
3 3