[R] plotting coxph results using survfit() function
Shoaaib Mehmood
shoaaib at gmail.com
Tue Nov 13 12:53:33 CET 2007
i want to make survival plots for a coxph object using survfit
function. mod.phm is an object of coxph class which calculated results
using columns X and Y from the DataFrame. Both X and Y are
categorical. I want survival plots which shows a single line for each
of the categories of X i.e. '4' and 'C'. I am getting the following
error:
> attach(DataFrame)
> DataFrame.X<-data.frame(X=c('4','C'),Y=rep(mean(Y),2))
> detach()
> plot(survfit(mod.phm, newdata=DataFrame.X), lty=c(1,2),ylim=c(.6,1))
Error in `contrasts<-`(`*tmp*`, value = "contr.treatment") :
contrasts can be applied only to factors with 2 or more levels
any help will be appreciated.
--
Regards,
Rana Shoaaib Mehmood
More information about the R-help
mailing list