Mercurial > repos > testtool > survival
diff survival/survival.R @ 0:6cc0c5eb71b2 draft
Uploaded
author | testtool |
---|---|
date | Fri, 29 Sep 2017 18:11:27 -0400 |
parents | |
children | 5b70a33bf327 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/survival/survival.R Fri Sep 29 18:11:27 2017 -0400 @@ -0,0 +1,18 @@ +args <- commandArgs(trailingOnly = TRUE) + +input =args[1] +fit = args[2] +png = args[3] + +#fit a Kaplan-Meier and plot it +input<-("test-data/input.csv") +fit <- survfit(Surv(obsT, status) ~ X1, type="kaplan-meier", conf.type="log", data=read.csv(input)) + +res <- summary(fit,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, file = "survfit.csv") + +png("fit.png") +plot(fit) +dev.off() +