ggrisktable | R Documentation |
A simple wrapper function which calculates the numbers at risk for a survival model and a given set of time points then creates a ggplot2 table with them.
ggrisktable( fit = NULL, times = NULL, text.color = "black", strata.order = NULL )
fit |
Required. survival::survfit() object. |
times |
Required. Numeric. One or more time points to calculate the number at risk for. |
text.color |
Optional. Character. Color of text within table. Defaults to 'black'. |
strata.order |
Optional. Character. Ordered names of strata factor levels. |
An unformatted ggplot2 table showing the number at risk.
library(survival) fit <- survfit(Surv(time, status) ~ trt, data = diabetic) ggrisktable( fit = fit, times = c(0, 10, 20, 30, 40, 50), strata.order = c('0', '1') ) + theme_risk()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.