我把你画图所需要的资料
通通抓出来
剩下的就由你自由发挥了.
######
library(Hmisc)
A<-read.csv("file.csv",header=TRUE)
attach(A)
out=rcspline.plot(factor,Time,model="cox",xrange=c(0,3),ylim=c(-1,2),event=event,nk=4,knots=c(0.8, 1.0,1.5,
2.0),showknots=TRUE,plotcl=FALSE,statloc="none",subset=SEX=="2",lty=2)
x=factor
xrange=c(0,3)
xe <- seq(xrange[1],xrange[2],length=600)
ylim=c(-1,2)
main <- "Estimated Spline Transformation"
xlim <- range(pretty(xe))
ylabl <- "log Relative Hazard"
xlab <- label(x)
lty=1
plot(out$x,out$xbeta,type="n",main=main,xlab=xlab,ylab=ylabl,xlim=xlim,ylim=ylim)
lines(xe,out$xbeta,lty=lty)
#######