[R] object of type 'S4' is not subsettable

Duncan Murdoch murdoch.duncan at gmail.com
Tue Apr 3 20:52:37 CEST 2012

On 03/04/2012 12:42 PM, phillen wrote:
> Figured it out.
> given that object 'cit' is of class S4, extracting information works as
> follows:
> 1)finding out names of slots in object 'cit'
> >  slotNames(cit)
>   [1] "x"         "Z0"        "Z1"        "ZK"        "type"      "model"
>   [7] "ecdet"     "lag"       "P"         "season"    "dumvar"    "cval"
> [13] "teststat"  "lambda"    "Vorg"      "V"         "W"         "PI"
> [19] "DELTA"     "GAMMA"     "R0"        "RK"        "bp"        "spec"
> [25] "call"      "test.name"
> 2) extracting info from wanted slot
> >  cit at teststat
> [1]  5.348440  9.068113 10.643293

That's one way.  There may be another:  if you print the class of cit using


there may be a help page, which you would find using


assuming "foo" is the name of the class.  The author may have defined a 
method to get what you want, or may give other guidance.  For example, 
in the Matrix package:

 > x <- Hilbert(6)
 > class(x)
[1] "dpoMatrix"
[1] "Matrix"
 > class?dpoMatrix

gives quite useful information about the dpoMatrix class.

Duncan Murdoch

More information about the R-help mailing list