Adds a column with the number of observations in each model, on the label rows, and the number of observations in each level, on the level rows. The observation counts come from the model matrix: a level's N is the number of observations at that level.
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.
See also
Other regression tables:
add_glance_table(),
add_global_p(),
add_nevent(),
add_significance_stars(),
add_vif(),
combine_terms(),
glance_fun_s3(),
global_pvalue_fun(),
tbl_regression(),
tbl_uvregression()
Examples
# Example 1 ----------------------------------
glm(response ~ age + grade, trial, family = binomial) |>
tbl_regression(exponentiate = TRUE) |>
add_n(location = "level")
# Example 2 ----------------------------------
trial |>
tbl_uvregression(y = age, include = c(marker, grade), method = lm, hide_n = TRUE) |>
add_n(location = c("label", "level"))