pharmaverse / ggsurvfit

http://www.danieldsjoberg.com/ggsurvfit/
Other
67 stars 19 forks source link

ggcuminc option to switch between showing multiple outcomes and strata as different linetypes and colors #166

Closed psoldath closed 8 months ago

psoldath commented 9 months ago

Is your feature request related to a problem? Please describe. ggcuminc defaults to show multiple outcomes as different linetypes and strata as different colors, but it is to my knowledge not possible to easily switch them, so outcomes will be shown as different colors and strata as different linetypes.

Describe the solution you'd like It would be a nice feature to be able to choose whether one wants outcomes and strata to be represented by linetypes and colors or by colors and linetypes, respectively. I can see they are in quosure form and they can be swapped using rlang quo_set_expr(), but this is only possible in cases where both multiple outcomes and multiple strata are present, as each mapping (linetype and color) is only generated when there is more than one value of the mapping. So it is not possible to e.g. make ggcuminc show multiple outcomes without strata as different colors instead of different linetypes.

ddsjoberg commented 9 months ago

@psoldath thanks for the post!

This has some up a number of times, so I should probably implement something.

NOTE TO SELF:

psoldath commented 9 months ago

@ddsjoberg thanks for the reply.. Yes, I agree that the best way would probably be to set the option as a global option. Or maybe it could simply be implemented as arguments in the ggcuminc() call like strata = "color" or "linetype" and outcome = "linetype" or "color"? I think in that way it would be kind of consistent with the other calls of ggsurvfit like add_risktable() with the possibility to customize the aesthetics in the call, such as add_risktable(risktable_stats = c("n.risk", "cum.event", "cum.censor"))

I'm really not good at R and coding, so I don't know if it would work in that way or if another solution would be better?

ddsjoberg commented 8 months ago

@psoldath i've implemented your request in this pull request (https://github.com/pharmaverse/ggsurvfit/pull/172). Can you please test the code to ensure it works as aticipated?