smed <- function(x) {
ox <- capture.output(print(x))
n <- length(ox)
tmp <- t(sapply(ox[4:n],
function(l) strsplit(l, split=' +')[[1]]))
nres <- strsplit(ox[3],split=' +')[[1]][2:6]
res <- matrix(as.numeric(tmp[,2:6]), ncol=5,
dimnames=list(tmp[,1], nres))
res
}
# example:
#library(survival)
#fit1 <- survfit(Surv(time, status) ~ 1, data=aml)
#sf1 <- smed(fit1)
#sf1
#fit <- survfit(Surv(time, status) ~ x, data=aml)
#sf <- smed(fit)
#sf
http://tolstoy.newcastle.edu.au/R/help/06/05/26713.html
By Xiaochun Li
No comments:
Post a Comment