ggrisktable {utile.visuals}R Documentation

Create a ggplot2 table showing the number at risk

Description

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.

Usage

ggrisktable(
  fit = NULL,
  times = NULL,
  text.color = "black",
  strata.order = NULL
)

Arguments

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.

Value

An unformatted ggplot2 table showing the number at risk.

Examples

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()

[Package utile.visuals version 0.3.3 Index]