Skip to contents

Adds a column with the number of events: on the label rows the events in the model, on the level rows the events at each level. Available for logistic and Poisson glm models and for coxph models, the models with an event count.

Usage

add_nevent(x, location = "label", ...)

Arguments

x

(tbl_regression, tbl_uvregression)
A regression table.

location

(character)
"label", "level" or both. "label" puts the model's N on the label rows, "level" puts each level's N on the level rows. Default is "label".

...

Not used.

Value

The table with a stat_nevent column.

Examples

# Example 1 ----------------------------------
glm(response ~ age + grade, trial, family = binomial) |>
  tbl_regression(exponentiate = TRUE) |>
  add_nevent()
# Example 2 ---------------------------------- glm(response ~ age + grade, trial, family = binomial) |> tbl_regression(exponentiate = TRUE) |> add_n(location = "level") |> add_nevent(location = "level")