[R] Survplot, Y-axis in percent

Andrews, Chris chrisaa at med.umich.edu
Wed Nov 7 14:18:51 CET 2012


It doesn't look like 'survplot' allows you to control the yaxis formatting in that way.  You can edit the function survplot.survfit directly if you really need to: fix(survplot.survfit).  The relevant line to change is (I believe) mgp.axis(2, at = pretty(ylim)) to mgp.axis(2, at = pretty(ylim), labels= 100*pretty(ylim)).  However, if you are new to R this could cause you more trouble than you want.

Alternatively, you can use 'plot' with the yaxt="n" option. e.g.,
mod <- survfit(Surv(time,status)~ph.ecog, data=lung)
plot(mod, yaxt="n", col=1:4, ylab="Survival Percent", xlab="Days", main="Lung Cancer Data\nEffect of ph.ecog on Survival")
axis(2, at=seq(0,1,0.2), labels=paste(seq(0,100,20), "%", sep=""), las=1)

But that doesn't have all the other stuff you appear to want (e.g., shaded confidence bands).

Good luck,
Chris

-----Original Message-----
From: maziar.mohaddes [mailto:maziar.mohaddes at gmail.com] 
Sent: Tuesday, November 06, 2012 11:11 AM
To: r-help at r-project.org
Subject: [R] Survplot, Y-axis in percent

Hi

I am a new fan of R after getting mad with the graphical functional in SPSS. 
I have been able to create a nice looking Kaplan Meyer graph using Survplot function. 
However I have difficulties in turning the y axis to percent instead of the default 0-1 scale.
Further I have tried the function yaxt="n" without any results. Any help in this matter will be appreciated. 
The code is posted below:

par(mfrow=c(1,1))
fit <- survfit(Surv(revreg$Tcuprev , revreg$Rcup_n_j_n)~revreg$RAceGrp_1Maz)
fit
survplot (fit, col=c("gray1","gray40"), lty=1, lwd = 1, col.fill=c("gray50","gray80"), 
          mark.time= T,  conf="bands" , conf.int=.95, add=F , 
          xlim=c(0, 20) , time.inc = 4, 
          ylim=c(0.5, 1), 
          xlab="Years Postoperative" , ylab="Cumulative Survival Probability" , 
          label.curves=F , abbrev.label=F , 
          yaxt="n"
          )




--
View this message in context: http://r.789695.n4.nabble.com/Survplot-Y-axis-in-percent-tp4648572.html
Sent from the R help mailing list archive at Nabble.com.


**********************************************************
Electronic Mail is not secure, may not be read every day, and should not be used for urgent or sensitive issues 




More information about the R-help mailing list