-
Notifications
You must be signed in to change notification settings - Fork 164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ggsurvplot, displaying time in years instead of days #166
Comments
New argument suggestion for x scale transformation xscale = c("d_m", "d_y", "m_d", "m_y", "y_d", "y_m") d_m: days to months |
To be added in ggsurvplot xscale = "d_m"
xtrans <- switch(xscale,
d_m = 12/365.25,
d_y = 1/365.25,
m_d = 365.25/12,
m_y = 1/12,
y_d = 365.25,
y_m = 12,
1
)
breaks <- c(0, 250, 500, 750, 1000)
p + scale_x_continuous(
breaks = breaks,
labels = round(breaks*xtrans,2)) |
|
Hi, I am using the flag "d_m" to convert my time scale in days to months. This works, but the months have decimals. I was wondering if there was a way to round them so they display as integers? Thank you, |
Also having the same issue as my months appear in decimals. For instance, I wanted to see 3, 6, 9, 12 months intervals, but instead it shows up as 3.29, 6.57, 9.86. Is there a way to round them? Thanks! |
A workaround is to add the argument "break.time.by=365.25*3" |
(e-mail from a user)
Hi
I continue to use your ggsurvplot and it’s really good, such a good package and nice to see you’re adding features such as the cumulative events table, no. censored subjects – great features!
Anyway, I wonder if there is a way of displaying time in years when it has been calculated in days. For example, I have some overall survival data calculated in days (it’s trivial to recalculate the OS in years), similar to the ‘xscale’ function in base plot.survfit
From the documentation;
https://stat.ethz.ch/R-manual/R-devel/library/survival/html/plot.survfit.html
“
xscale
a numeric value used like yscale for labels on the x axis. A value of 365.25 will give labels in years instead of the original days.
“
I think this would be a useful addition.
The text was updated successfully, but these errors were encountered: