Zhengdeng Lei, PhD

Zhengdeng Lei, PhD

2009 - Present Research Fellow at Duke-NUS, Singapore
2007 - 2009 High Throughput Computational Analyst, Memorial Sloan-Kettering Cancer Center, New York
2003 - 2007 PhD, Bioinformatics, University of Illinois at Chicago

Friday, April 15, 2011

Median survival time

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