Feature description
Suggestion for a new function tbl_coxph which computes the pairwise cox proportional hazards test and returns a gtsummary object of the results as below. This could rely on the get_cox_pairwise_df() function for computation and simply work on formatting these results into a table? Or it could compute the results itself if that is easier.
Example
library(NEST.TLGs)
library(tidyverse)
adam_db <- syntheticadam::get_data("adtte")
# data pre-processing ----------------------------------------------------------
arm_var <- "TRT01P"
df_ttet01 <- adam_db$adtte |>
dplyr::filter(PARAMCD == "PFS" & ANL01FL == "Y") |>
mutate(is_event = CNSR == 0,
is_not_event = CNSR == 1,
first_event = ifelse(CNSR == 0, EVNTDESC, NA_character_))
# Set the treatment arm variable as a factor with levels in desired order
df_ttet01[[arm_var]] <- factor(df_ttet01[[arm_var]], levels = c(
"Placebo",
"Xanomeline Low Dose",
"Xanomeline High Dose"
))
# Build Cox PH Model --------------------------------------------------------------------
coxph_formula <- as.formula(sprintf("Surv(AVAL, is_event) ~ %s", arm_var))
df_coxph <- df_ttet01 |>
get_cox_pairwise_df(
model_formula = coxph_formula,
arm = arm_var
)
As you can see, this code generates the necessary statistics but does not format this in a gtsummary object.
Code of Conduct
Contribution Guidelines
Security Policy
Feature description
Suggestion for a new function
tbl_coxphwhich computes the pairwise cox proportional hazards test and returns a gtsummary object of the results as below. This could rely on theget_cox_pairwise_df()function for computation and simply work on formatting these results into a table? Or it could compute the results itself if that is easier.Example
As you can see, this code generates the necessary statistics but does not format this in a
gtsummaryobject.Code of Conduct
Contribution Guidelines
Security Policy