Mercurial > repos > testtool > survival
comparison survival/survival.R @ 0:6cc0c5eb71b2 draft
Uploaded
author | testtool |
---|---|
date | Fri, 29 Sep 2017 18:11:27 -0400 |
parents | |
children | 5b70a33bf327 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:6cc0c5eb71b2 |
---|---|
1 args <- commandArgs(trailingOnly = TRUE) | |
2 | |
3 input =args[1] | |
4 fit = args[2] | |
5 png = args[3] | |
6 | |
7 #fit a Kaplan-Meier and plot it | |
8 input<-("test-data/input.csv") | |
9 fit <- survfit(Surv(obsT, status) ~ X1, type="kaplan-meier", conf.type="log", data=read.csv(input)) | |
10 | |
11 res <- summary(fit,times=c(1,2,3)) | |
12 save.df <- as.data.frame(res[c("strata", "time", "n.risk", "n.event", "surv", "std.err", "lower", "upper")]) | |
13 write.csv(save.df, file = "survfit.csv") | |
14 | |
15 png("fit.png") | |
16 plot(fit) | |
17 dev.off() | |
18 |