2012-11-01 108 views
1

我正在使用生存包生成两个群体的KM曲线,但是当我尝试定义xmax参数时,我无法扩展x轴范围从0-15 0 - 50.R:生存包中的KM曲线图更改x轴范围

这是我的代码:

library(sm) 
library(survival) 
comb = read.csv("S:/Novocure/ChemoSKTime2Resp.csv", head = TRUE) 
comb 
survobj = with(comb, Surv(SK.response.time,Censored)) 
survobj 

# Compare the survival distributions of nonresponders(0) and responders(1) 

fitresp = survfit(survobj ~ response, data=comb) 
fitresp 
summary(fitresp) 

# plot the survival distributions by response 

plot(fitresp, xlab="Tumor Progression Time in Months", 
    ylab="% Progressed", yscale=100, col=c("red","blue"), 
    main="Chemo Time to Tumor Progression Distribution", xmax = 50) 
    legend("topright", title="Chi-sq = 5.2, P = 0.0222", 
    c("Non-responders", "Responders"), fill=c("red", "blue")) 
+1

这是形式真正的穷人,包括'RM(名单= LS())'在你的例子代码 - 一个天真的SO用户可以在会话其中运行他们也在工作。 – mnel

+2

另外,我们应该如何访问您的CSV文件? – mnel

回答

3

xmax参数plot.survfit似乎仅缩短x轴的范围内。为了扩展它,使用参数xlim代替:

plot(fitresp, xlab="Tumor Progression Time in Months", 
    ylab="% Progressed", yscale=100, col=c("red","blue"), 
    main="Chemo Time to Tumor Progression Distribution", xlim = c(0,50))