Closed bailliem closed 2 years ago
I've seen examples where the risk table has more/less time point shown than those listed on the figure axis, so I don't think we should link them.
At first, it seems natural that the ggsurvfit(times=)
should exist. But the only hesitation I have with add it is that the axis specification is in a scale_()
meaning we would need to include a call like ggplot2::scale_x_continuous(breaks=c(0, 2, 30))
inside ggsurvfit()
. If the user later tried to use a scale option (like formatting the numbers on the axis), the scale that we previously set is replaced (not stacked).
In the example below the user would have requested times 0, 2, and 30 in ggsurvfit()
, but then those instructions would have been erased later by the user....this will be very mysterious to them I think.
library(ggsurvfit)
p <-
survfit2(Surv(time, status) ~ sex, data = df_lung) |>
ggsurvfit() +
add_risktable(times = c(0, 2, 30))+
ggplot2::scale_x_continuous(breaks=c(0, 2, 30)) +
ggplot2::scale_x_continuous(labels = gtsummary::style_sigfig)
#> Scale for 'x' is already present. Adding another scale for 'x', which will
#> replace the existing scale.
p
Created on 2022-08-10 by the reprex package (v2.0.1)
updated documentation to make it more clear
Is your feature request related to a problem? Please describe.
At the moment if a user passes in a times arguement in to the risk table which does not match the default x-axis breaks, then there will be a mismatch during print.
How important is it to automatically display the x-axis tick marks to match up with any user inputed times arguement?
I'm not sure this is necessary, the risk being it could add complexity and also be opqaue for the user to control the functionality.
For example. it can be handled easily as is by modifying the breaks on the x-axis. So an easy fix would be to add this an example in the documentation.