changeset 4:744cf0f4d1b1 draft

Uploaded
author testtool
date Mon, 02 Oct 2017 07:54:25 -0400
parents e31c47bf46a4
children a971f430b5d3
files survival/survival.R
diffstat 1 files changed, 11 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/survival/survival.R	Mon Oct 02 07:54:12 2017 -0400
+++ b/survival/survival.R	Mon Oct 02 07:54:25 2017 -0400
@@ -1,17 +1,23 @@
 require(survival, quietly = TRUE)
 args <- commandArgs(trailingOnly = TRUE)
 
-input =args[1]
-fit = args[2]
-png = args[3]
+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="kaplan-meier", conf.type="log", data=read.csv(input))
+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)
+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()