I am trying to change the y-axis for my Kaplan Meier survival function. I am using autoplot to create a ggplot for a survfit object. It is in the survMisc library.
The output currently has the y-axis from 0 to 1, but I would like to change it to 0.5 to 1. There does not appear to be an argument within autoplot that allows me to change the axis.
If this is possible, I would also like to change the intervals of my tick marks. It currently has it at every 2.5 years (minor axis) but I would like it every year.
I have attached a sample survival code from the UCLA website, but my autoplot code is the same as in my script. Thanks.
hmohiv<-read.table("http://www.ats.ucla.edu/stat/r/examples/asa/hmohiv.csv", sep=",", header = TRUE)
library(survival)
library(ggplot2)
library(Hmisc)
library(ggfortify)
attach(hmohiv)
hmohiv.surv <- survfit( Surv(time, censor)~ 1)
summary(hmohiv.surv)
autoplot(hmohiv.surv, type = "CI", palette="Set2", pVal=TRUE,
title="Recurrence Free Survival",
legTitle = "Adjuvant Treatment",
xLab="Years to Recurrence", yLab="Probability",
censSize = 2,
alpha = 0.9,
tabTitle = "Number at Risk",
tabTitleSize = 14,
tabLabSize = 2,
nRiskSize = 4,
timeTicks = "minor"
) + scale_y_continuous(limits=c(0.5,1))
It runs fine without the
+ scale_y_continuous(limits=c(0.5,1))
but when I run it with the scale, it gives me the following error:
Error in autoplot(hmohiv.surv, type = "CI", palette = "Set2", pVal = TRUE, : non-numeric argument to binary operator