Skip to content

object of type 'S4' is not subsettable

4 messages · phillen, Duncan Murdoch

#
hey there!

The object 'cit' contains:
##################################################### 
# Johansen-Procedure Unit Root / Cointegration Test # 
##################################################### 

The value of the test statistic is: 5.3484 9.0681 10.6433
---------------
I want R to save the value 5.3484 in a new object. I am used to use the
command x=cit[a] where a stands for the place where R has saved the value.
However, the johansen procedure works with S4 objects with which subsetting
does not seem to work.

Any ideas how I could get R save a certain value of the output into a new
object?

Thousand thanks,
Philipp

--
View this message in context: http://r.789695.n4.nabble.com/object-of-type-S4-is-not-subsettable-tp4529063p4529063.html
Sent from the R help mailing list archive at Nabble.com.
#
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'
[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
[1]  5.348440  9.068113 10.643293



--
View this message in context: http://r.789695.n4.nabble.com/object-of-type-S4-is-not-subsettable-tp4529063p4529432.html
Sent from the R help mailing list archive at Nabble.com.
#
On 03/04/2012 12:42 PM, phillen wrote:
That's one way.  There may be another:  if you print the class of cit using

class(cit)

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

class?foo

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"
attr(,"package")
[1] "Matrix"
 > class?dpoMatrix

gives quite useful information about the dpoMatrix class.

Duncan Murdoch