1
|
1 require(survival, quietly = TRUE)
|
0
|
2 args <- commandArgs(trailingOnly = TRUE)
|
|
3
|
|
4 input =args[1]
|
|
5 fit = args[2]
|
|
6 png = args[3]
|
|
7
|
|
8 #fit a Kaplan-Meier and plot it
|
|
9 input<-("test-data/input.csv")
|
1
|
10 fit <- survival::survfit(Surv(obsT, status) ~ X1, type="kaplan-meier", conf.type="log", data=read.csv(input))
|
0
|
11
|
|
12 res <- summary(fit,times=c(1,2,3))
|
|
13 save.df <- as.data.frame(res[c("strata", "time", "n.risk", "n.event", "surv", "std.err", "lower", "upper")])
|
|
14 write.csv(save.df, file = "survfit.csv")
|
|
15
|
|
16 png("fit.png")
|
|
17 plot(fit)
|
|
18 dev.off()
|
|
19
|