Reputation: 39
I use tbl_regression from the gtsummary package to depict a Cox proportional hazards model in a table and want to add follow-up time/person years to my tbl_regression table, but cannot seem to find out how to do this.
Can anyone help? Thank you!
Best, Mathilde
cox_cat_noncns <- coxph(Surv(TTD, Dod_status) ~ Highest_Edu_Household, data = data_cox_cat_noncns)
cox_cat_noncns_udj_table <- tbl_regression(cox_cat_noncns,
label = Highest_Edu_Household ~ "Highest parental education",
exponentiate = TRUE %>%
add_nevent(location = "level") %>%
bold_labels() %>%
italicize_levels() %>%
modify_tabel_styling(
columns = estimate,
rows = reference_row %in% TRUE,
missing_symbol = "Ref.") %>%
modify_footnote(everything() ~ NA, abbreviation = TRUE) %>%
modify_table_styling(
column = p.value,
hide = TRUE) %>%
modify_header(
label= "")
Upvotes: 2
Views: 408
Reputation: 11719
There is a hidden column in the table with the total exposure time. The column is hidden by default, and you can unhide it using the modify_header()
function (columns with assigned headers are unhidden). To see all columns available, inspect the tbl$table_body
data frame. Happy Porgramming!
library(gtsummary)
library(survival)
packageVersion("gtsummary")
#> [1] '1.5.2'
tbl <-
coxph(Surv(ttdeath, death) ~ age, trial) %>%
tbl_regression(exponentiate = TRUE) %>%
modify_header(exposure ~ "**Exposure**")
Created on 2022-04-17 by the reprex package (v2.0.1)
Upvotes: 1