R:KM曲线在生存包变化x轴范围内绘制
我正在使用生存包为两个种群生成KM曲线,但当我试图定义xmax参数时,我无法将x轴范围从0-15扩展到0-50 这是我的密码:R:KM曲线在生存包变化x轴范围内绘制,r,plot,R,Plot,我正在使用生存包为两个种群生成KM曲线,但当我试图定义xmax参数时,我无法将x轴范围从0-15扩展到0-50 这是我的密码: 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
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"))
plot.survfit
的xmax
参数似乎只会缩短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))
在示例代码中包含
rm(list=ls())
是一种非常糟糕的形式——一种幼稚的方式,用户可以在他们工作的会话中运行它。另外,我们应该如何访问您的csv文件?