Extract a column from an event history object, as obtained with the function
Hist
.
getEvent(object, mode = "factor", column = "event")
Since objects of class "Hist"
are also matrices, all columns are
numeric or integer valued. To extract a correctly labeled version, the
attribute states
of the object is used to generate factor levels.
dat= data.frame(time=1:5,event=letters[1:5])
x=with(dat,Hist(time,event))
## inside integer
unclass(x)
#> time status event
#> [1,] 1 1 1
#> [2,] 2 1 2
#> [3,] 3 1 3
#> [4,] 4 1 4
#> [5,] 5 1 5
#> attr(,"states")
#> [1] "a" "b" "c" "d" "e"
#> attr(,"cens.type")
#> [1] "uncensored"
#> attr(,"cens.code")
#> [1] "0"
#> attr(,"model")
#> [1] "competing.risks"
#> attr(,"entry.type")
#> [1] ""
## extract event (the extra level "unknown" is for censored data)
getEvent(x)
#> [1] a b c d e
#> Levels: a b c d e unknown