library(rms)
library(ggplot2)
library(scales)
dt<-smoke
dd<-datadist(dt)
options(datadist='dd')
fit<- cph(Surv(time,status==1) ~ rcs(age,4)+gender, x=TRUE, y=TRUE,data=dt)
###one group
singlercs(data=dt,fit=fit,x="age")
##two groups
singlercs(data=dt,fit=fit,x="age",group="gender")
Run the code above in your browser using DataLab