add_n.tbl_survfit: Add N

View source: R/add_n.tbl_survfit.R

add_n.tbl_survfitR Documentation

Add N

Description

For each survfit() object summarized with tbl_survfit() this function will add the total number of observations in a new column.

Usage

## S3 method for class 'tbl_survfit'
add_n(x, ...)

Arguments

x

object of class "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()


ddsjoberg/gtsummary documentation built on Sept. 16, 2024, 4:15 a.m.