2012-04-06 30 views
0

我做了生存分析,并产生了使用在R和ggplot2包中,如何添加行?

  1. 积函数绘制的Kaplan-Meier(KA变量)估计作为对时间的y值的生存曲线图。

  2. 线的作用来绘制估计i和i + 1之间的台阶线,对于每个i = 1,2,....

的代码如下:

plot(KA) 

for(i in 1:(length(KA)-1)){ 

lines(c(i,i+1),c(KA[i],KA[i]))  # The horizontal step lines 

lines(c(i+1,i+1),c(KA[i],KA[i+1])) # The vertical step lines 

} 

现在我想用ggplot2软件包制作一个更漂亮的生存图。

问题是:如何在图表中添加步骤行?

我很抱歉,我不能把图形作为我的名誉小于10

+0

继这里的建议将产生更好的答案,为您和社区:http://stackoverflow.com/questions/5963269/how-to-make-a-great-r - 可重复生成的示例 – Chase 2012-04-06 21:09:14

+0

以下是一些示例代码:http://www.ceb-institute.org/bbs/wp-content/uploads/2011/09/ggplot2-tutorial-code.txt – EDi 2012-04-06 21:15:06

回答