Mercurial > repos > testtool > survival
view survival/survival.R @ 25:a0ae4293a398 draft
Uploaded
author | testtool |
---|---|
date | Mon, 02 Oct 2017 09:47:09 -0400 |
parents | b4d7a110dd32 |
children | ef13fa666e0e |
line wrap: on
line source
require(survival, quietly = TRUE) args <- commandArgs(trailingOnly = TRUE) input = args[1] type = args[2] error = args[3] conf_type = args[4] conf_lower = args[5] fit = args[6] png = args[7] tofit <- survival::survfit(Surv(obsT, status) ~ X1, type = type, error = error, conf.type = conf_type , conf.lower = conf_lower, data = read.csv(input)) res <- summary(tofit,times=c(1,2,3)) save.df <- as.data.frame(res[c("strata", "time", "n.risk", "n.event", "surv", "std.err", "lower", "upper")]) write.csv(save.df, fit) png(png) plot(tofit,xlab="Survival (days)", ylab="Survival", lwd=2,xlim=c(0,1900),ylim=c(0.3,1),col=c("red","blue")) legend("topright",legend=c("low","high"),lty=c(1,1), lwd=c(2.5,2.5),col=c("red","blue")) dev.off()