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 ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.