From 493fedefc5683fcab51243b1f4e600b6d9599029 Mon Sep 17 00:00:00 2001 From: Emily de la Rua <59304861+edelarua@users.noreply.github.com> Date: Thu, 12 Oct 2023 10:16:38 -0400 Subject: [PATCH] Fix `g_km` unit conversion bug (#1082) Fixes insightsengineering/teal.modules.clinical#837 --- NEWS.md | 3 +++ R/kaplan_meier_plot.R | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index a6ad352d49..13b135d814 100644 --- a/NEWS.md +++ b/NEWS.md @@ -7,6 +7,9 @@ * Added formatting function `format_count_fraction_lt10` for formatting `count_fraction` with special consideration when count is less than 10. * Updated `s_summary.logical` output for `count_fraction` when denominator is zero to display as `NA` instead of `0` in tables. +### Bug Fixes +* Fixed bug in `g_km` causing an error when converting certain annotation width units. + ### Miscellaneous * Began deprecation of `na_level` argument in `s_count_abnormal_by_baseline`, `a_summary`, `analyze_vars`, `analyze_vars_in_cols`, `compare_vars`, `h_map_for_count_abnormal`, `h_stack_by_baskets`, `summarize_colvars`, `a_coxreg`, and `summarize_coxreg` and replaced it with the `na_str` argument. diff --git a/R/kaplan_meier_plot.R b/R/kaplan_meier_plot.R index 3c64c4650a..3ee070afde 100644 --- a/R/kaplan_meier_plot.R +++ b/R/kaplan_meier_plot.R @@ -1217,7 +1217,7 @@ h_grob_median_surv <- function(fit_km, ttheme = gridExtra::ttheme_default()) { data <- h_tbl_median_surv(fit_km, armval = armval) - width <- grid::convertUnit(width, "in") + width <- grid::convertUnit(grid::unit(as.numeric(width), grid::unitType(width)), "in") height <- width * (nrow(data) + 1) / 12 w <- paste(" ", c( @@ -1425,7 +1425,7 @@ h_grob_coxph <- function(..., )) { data <- h_tbl_coxph_pairwise(...) - width <- grid::convertUnit(width, "in") + width <- grid::convertUnit(grid::unit(as.numeric(width), grid::unitType(width)), "in") height <- width * (nrow(data) + 1) / 12 w <- paste(" ", c(