There is another function that you could use that gives you better graphics and is a bit more customizable than the generic plot function. It is the survplot() function, which is contained in the rms library. Since we will want to demonstrate this function in a few different ways with varying parameters, we will wrap a few of the native functions into a new function called Plotsurv(), which will allow us to customize some of the plots.
First, define the function:
library(rms)plotsurv <- function(x,y,z=c('bars'),zz=FALSE){ objNpsurv <- npsurv(formula = Surv(Xtenure2,Churn ==1) ~ x, data = ChurnStudy) class(objNpsurv) survplot(objNpsurv,col=c('green','red','blue','yellow','orange','purple'), label.curves=list(keys=y),xlab='Months',conf=z,conf.int=.95,n.risk=zz) ...