Skip to content

Instantly share code, notes, and snippets.

@maromato
Created February 29, 2016 01:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maromato/6033ef5e673b482bdf81 to your computer and use it in GitHub Desktop.
Save maromato/6033ef5e673b482bdf81 to your computer and use it in GitHub Desktop.
#https://www1.doshisha.ac.jp/~mjin/R/36/36.htmlが参考になる。
#ID, OS, Status, DrugからなるTableを作る!
#ID= Patient Number,OS =length of time, Status =Death or Not, Drug=Control or test
library(survival)
#ファイルの読み込み
t <- read.table(file="FILE NAME.txt",header=T,sep="t",row.names=1)
#分析
attach(t)
t.surv <- survfit( Surv(OS, Status)~ Drug conf.type="none")
summary(t.surv)
#KMプロット作成
plot (t.surv,lty=1:2, xlab="Time", ylab="Survival Probability" )
legend(locator(1),c("Drug -","Drug +"),lty=c(1,2))
#Statistical analysis
survdiff(Surv(OS)~Drug,data=t)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment