add_n.tbl_survfit: Add column with number of observations

add_n.tbl_survfitR Documentation

Add column with number of observations

Description

\lifecycle

maturing 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

Example Output

Example 1

image of rendered example table

See Also

Review list, formula, and selector syntax used throughout gtsummary

Other tbl_survfit tools: add_nevent.tbl_survfit(), add_p.tbl_survfit(), modify, tbl_merge(), tbl_split(), tbl_stack(), tbl_strata(), tbl_survfit()

Examples



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

# Example 1 ----------------------------------
add_n.tbl_survfit_ex1 <-
  list(fit1, fit2) %>%
  tbl_survfit(times = c(12, 24)) %>%
  add_n()



gtsummary documentation built on Jan. 13, 2023, 9:10 a.m.