Skip to content

Commit

Permalink
Fix bug in tm_t_coxreg when no covariates selected (#833)
Browse files Browse the repository at this point in the history
Closes #832
  • Loading branch information
edelarua authored Sep 25, 2023
1 parent f58819c commit 2b20a85
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
* Refactored `tm_t_exposure` to display "total" row as last row in table instead of as a summary row. Added parameters `add_total_row` to set whether the total row should be displayed and `total_row_label` to set the total row label.
* Update `tm_t_events` to maintain indentation after pruning.

### Bug fixes
* Fixed bug in `tm_t_coxreg` preventing table from being displayed when no covariates are selected.

### Miscellaneous
* Updated `control_incidence_rate` parameter names in `tm_t_events_patyear` from `time_unit_input` and `time_unit_output` to `input_time_unit` and `num_pt_year`, respectively, after parameter names were changed in `tern`.
* Hid the datasets that were not being used by the _patient profile_ modules in the filter panel. Replaced the `datanames = "all"` parameter with the datasets used internally by the module.
Expand Down
10 changes: 4 additions & 6 deletions R/tm_t_coxreg.R
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,9 @@ template_coxreg_u <- function(dataname,
)
)

variables <- list(
time = aval_var, event = "event", arm = arm_var, covariates = cov_var
)
variables <- list(time = aval_var, event = "event", arm = arm_var)

if (!is.null(cov_var)) variables$covariates <- cov_var
if (!is.null(strata_var)) variables$strata <- strata_var

y$data <- bracket_expr(data_list)
Expand Down Expand Up @@ -224,10 +223,9 @@ template_coxreg_m <- function(dataname,
)
)

variables <- list(
time = aval_var, event = "event", arm = arm_var, covariates = cov_var
)
variables <- list(time = aval_var, event = "event", arm = arm_var)

if (!is.null(cov_var)) variables$covariates <- cov_var
if (!is.null(strata_var)) variables$strata <- strata_var

y$data <- bracket_expr(data_list)
Expand Down
18 changes: 8 additions & 10 deletions tests/testthat/_snaps/tm_t_coxreg.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@
main_footer = c("p-value method for Coxph (Hazard Ratio): wald",
"Ties for Coxph (Hazard Ratio): efron")) %>% rtables::append_topleft("OS") %>%
summarize_coxreg(variables = list(time = "AVAL", event = "event",
arm = "ARMCD", covariates = NULL, strata = "STRATA1"),
control = list(pval_method = "wald", ties = "efron",
conf_level = 0.95, interaction = FALSE), at = list(AGE = c(35,
45)), multivar = FALSE, .stats = c("n", "hr", "ci",
"pval"))
arm = "ARMCD", strata = "STRATA1"), control = list(pval_method = "wald",
ties = "efron", conf_level = 0.95, interaction = FALSE),
at = list(AGE = c(35, 45)), multivar = FALSE, .stats = c("n",
"hr", "ci", "pval"))
$table
result <- rtables::build_table(lyt = lyt, df = anl)
Expand All @@ -48,11 +47,10 @@
main_footer = c("p-value method for Coxph (Hazard Ratio): wald",
"Ties for Coxph (Hazard Ratio): efron")) %>% rtables::append_topleft("OS") %>%
summarize_coxreg(variables = list(time = "AVAL", event = "event",
arm = "ARMCD", covariates = NULL, strata = "STRATA1"),
control = list(pval_method = "wald", ties = "efron",
conf_level = 0.95, interaction = TRUE), at = list(AGE = c(35,
45)), multivar = FALSE, .stats = c("n", "hr", "ci",
"pval", "pval_inter"))
arm = "ARMCD", strata = "STRATA1"), control = list(pval_method = "wald",
ties = "efron", conf_level = 0.95, interaction = TRUE),
at = list(AGE = c(35, 45)), multivar = FALSE, .stats = c("n",
"hr", "ci", "pval", "pval_inter"))
$table
result <- rtables::build_table(lyt = lyt, df = anl)
Expand Down

0 comments on commit 2b20a85

Please sign in to comment.