Description Usage Arguments Value Author(s) Examples
Creates a numbers at risk table based on a ggplot object created by the plot_survfit function. It will add a table in the lower part of the plot, with numbers where the X axis tick marks are situated.
1 2 3 |
g |
a ggplot object to which a numbers at risk table should be added. |
size |
a numeric value indicating the font size of the NAR table |
x_offset |
a constant indicating how much padding should be placed to the left of the NAR table (a multiple of the plot size in the X dimension) |
y_offset |
a constant indicating how much each line in the NAR table should be offset (as a multiple of both the plotting space size and the row number) |
forced_height |
a constant that, if provided, will force the NAR table to be of a certain height. This represents a multiple of the plot size in the Y dimension. This overrides the y_offset setting. Useful when you wish to plot multiple plots along side each other where the number of strata differs, as this setting will ensure that the sizes of the NAR tables are constant. |
flip |
a logical scalar indicating wheter the order in rows of the NAR table should be flipped or not. |
separator |
a logical scalar indicating whether a line that separates the plot from the NAR table should be put in place |
sep_lwd |
what width should that line have? |
sep_color |
which color should we use for that line? |
Returns a ggplot object
Daniel Lindholm
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | library(survsup); library(ggplot2); library(dplyr); library(survival)
retinopathy %>%
survfit(Surv(futime, status) ~ trt, data = .) %>%
plot_survfit() %>%
nar()
# Without table flip:
flchain %>%
survfit(Surv(futime, death) ~ sex, data = .) %>%
plot_survfit(cuminc = FALSE) %>%
nar()
# With table flip:
flchain %>%
survfit(Surv(futime, death) ~ sex, data = .) %>%
plot_survfit(cuminc = FALSE) %>%
nar(flip = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.