Mercurial > repos > testtool > survival
comparison survival/survival.R @ 1:5b70a33bf327 draft
Uploaded
author | testtool |
---|---|
date | Fri, 29 Sep 2017 18:32:23 -0400 |
parents | 6cc0c5eb71b2 |
children | ce6df2bd21cd |
comparison
equal
deleted
inserted
replaced
0:6cc0c5eb71b2 | 1:5b70a33bf327 |
---|---|
1 require(survival, quietly = TRUE) | |
1 args <- commandArgs(trailingOnly = TRUE) | 2 args <- commandArgs(trailingOnly = TRUE) |
2 | 3 |
3 input =args[1] | 4 input =args[1] |
4 fit = args[2] | 5 fit = args[2] |
5 png = args[3] | 6 png = args[3] |
6 | 7 |
7 #fit a Kaplan-Meier and plot it | 8 #fit a Kaplan-Meier and plot it |
8 input<-("test-data/input.csv") | 9 input<-("test-data/input.csv") |
9 fit <- survfit(Surv(obsT, status) ~ X1, type="kaplan-meier", conf.type="log", data=read.csv(input)) | 10 fit <- survival::survfit(Surv(obsT, status) ~ X1, type="kaplan-meier", conf.type="log", data=read.csv(input)) |
10 | 11 |
11 res <- summary(fit,times=c(1,2,3)) | 12 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 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 write.csv(save.df, file = "survfit.csv") |
14 | 15 |