view survival/survival.R @ 31:ef13fa666e0e draft default tip

Uploaded
author testtool
date Tue, 03 Oct 2017 09:40:44 -0400
parents b4d7a110dd32
children
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="Time", 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()