Skip to contents

Adds a column with the number of observations in each model of a table created with tbl_survfit(), on the label rows. Called as add_n() on a tbl_survfit object. The count is the number of observations the curves were estimated from, sum(x$n) of the survfit object.

Value

A tbl_survfit table with an N column.

Arguments

  • x (tbl_survfit)
    A table created with tbl_survfit().

  • ... Not used.

Examples

library(survival)
fit1 <- survfit(Surv(ttdeath, death) ~ 1, trial)
fit2 <- survfit(Surv(ttdeath, death) ~ trt, trial)

# Example 1 ----------------------------------
list(fit1, fit2) |>
  tbl_survfit(times = c(12, 24)) |>
  add_n()