2012-11-01 137 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))