[R] Printing output on Plot

Neil Leonard nleonard at tartarus.uwa.edu.au
Fri Sep 3 04:11:33 CEST 2004


Hi,

I'm trying to print the p-values from the output of a CPH test onto a  
Kaplan Meier plot. Can this be done? I only really want the p-values  
from the CPH test to appear but if this can't be done I am willing to  
have the entire CPH output.

This is what I am currently trying: (it doesn't print the CPH output)

plot_KM <- function(field)
{
	library(survival)
	y = length(levels(factor(field)))
	field.KM <- survfit(Surv(age_at_death,death)~field)
	field.CPH <- coxph(Surv(age_at_death,death)~factor(field))
	plot(field.KM,mark.time=FALSE,col=2: 
(y+1),lty=1,main=paste(as.character(substitute(field))," Kaplan-Meier  
Plot"))
	text(1000, .3, paste(as.character(field.CPH)), col="red")
	legend(1000, .5, levels(factor(field)), col=2:(y+1), lty=1)
}


Thanks,
Neil




More information about the R-help mailing list