I could not find syntax to add at risk table inside of KM plot and color code groups like SAS do. I know the package was published recently, so I'm not sure if there is any syntax for that.
I followed the guidance [https://www.danieldsjoberg.com/ggsurvfit/reference/add_risktable.html] to use ggsurvfit to generate KM plot.
The examples are fairly clear on the help pages. Here's an example of a color-coded KM with a risk table, using the
df_lung
data frame that comes with the ggsurvfit package:EDIT
If you are looking for something more bespoke, with the risk table as part of the main panel, you can place the text directly in it, but it requires some precalculation:
The plot is now: