From 9f0e1594d05668d5dc376e134c3764b2c8b70aeb Mon Sep 17 00:00:00 2001 From: shajoezhu Date: Wed, 18 Sep 2024 11:50:18 +0800 Subject: [PATCH 1/6] prep for rspm release 0.9.6, [skip vbump] --- DESCRIPTION | 4 ++-- NEWS.md | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 3a8c073660..6b8cb09194 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: tern Title: Create Common TLGs Used in Clinical Trials -Version: 0.9.5.9025 +Version: 0.9.6 Date: 2024-09-17 Authors@R: c( person("Joe", "Zhu", , "joe.zhu@roche.com", role = c("aut", "cre")), @@ -34,7 +34,7 @@ Imports: dplyr (>= 1.0.0), emmeans (>= 1.10.4), forcats (>= 1.0.0), - formatters (>= 0.5.9), + formatters (>= 0.5.8), ggplot2 (>= 3.5.0), grid, gridExtra (>= 2.0.0), diff --git a/NEWS.md b/NEWS.md index 34806c70da..a29559a470 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,17 +1,17 @@ -# tern 0.9.5.9025 +# tern 0.9.6 ### Enhancements * Added `errorbar_width` and `linetype` parameters to `g_lineplot`. -* Reworking of `summarize_glm_count()` documentation and all its associated functions to better describe the results and the functions' purpose. * Added the `.formats` argument to `tabulate_rsp_subgroups` and `tabulate_survival_subgroups` to allow users to specify formats. * Added the `riskdiff` argument to `tabulate_rsp_subgroups` and `tabulate_survival_subgroups` to allow users to add a risk difference table column, and function `control_riskdiff` to specify settings for the risk difference column. * Added warning to `tabulate_rsp_subgroups` when `pval` statistic is selected but `df` has not been correctly generated to add p-values to the output table. * Added `n_rate` statistic as a non-default option to `estimate_incidence_rate` which returns both number of events observed and estimated incidence rate. * Added `fraction` statistic to the `analyze_var_count` method group. +* Improved `summarize_glm_count()` documentation and all its associated functions to better describe the results and the functions' purpose. ### Bug Fixes -* Fixed a bug in `a_surv_time` that threw an error when split only has `"is_event"`. * Added defaults for `d_count_cumulative` parameters as described in the documentation. -* Empty levels on `g_lineplot` x-axis are not shown in either plots. +* Fixed a bug of empty levels on `g_lineplot` x-axis were not shown in either plots. +* Fixed a bug in `a_surv_time` that threw an error when split only has `"is_event"`. * Fixed disappearing line in `g_lineplot` when using only one group or strata level. * Fixed defaults for formats and labels in `get_formats_from_stats` and `get_labels_from_stats`. * Fixed bug for linear scaling factor (`scale` parameter) being applied to response but not to rate in `h_glm_count` while all distributions have logarithmic link function. From 5838eb284d5b845ee745fef50d925c9e194e07a0 Mon Sep 17 00:00:00 2001 From: shajoezhu Date: Mon, 23 Sep 2024 11:41:54 +0800 Subject: [PATCH 2/6] update url --- vignettes/tables.Rmd | 2 +- vignettes/tern.Rmd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/vignettes/tables.Rmd b/vignettes/tables.Rmd index 9feba45514..4f15efc61b 100644 --- a/vignettes/tables.Rmd +++ b/vignettes/tables.Rmd @@ -27,7 +27,7 @@ knitr::opts_chunk$set( The `tern` R package provides functions to create common analyses from clinical trials in `R`. The core functionality for tabulation is built on the more general purpose `rtables` package. -New users should first begin by reading the ["Introduction to tern"](https://insightsengineering.github.io/tern/main/articles/tern.html) and ["Introduction to `rtables`"](https://insightsengineering.github.io/rtables/latest-tag/articles/introduction.html) vignettes. +New users should first begin by reading the ["Introduction to tern"](https://insightsengineering.github.io/tern/main/articles/tern.html) and ["Introduction to `rtables`"](https://insightsengineering.github.io/rtables/latest-tag/articles/rtables.html) vignettes. The packages used in this vignette are: diff --git a/vignettes/tern.Rmd b/vignettes/tern.Rmd index 0920bff77d..91d4d85e53 100644 --- a/vignettes/tern.Rmd +++ b/vignettes/tern.Rmd @@ -32,7 +32,7 @@ The `tern` R package contains analytical functions for creating tables and graph The main focus is on the clinical trial reporting tables but the graphs related to the clinical trials are also valuable. The core functionality for tabulation is built on top of the more general purpose `rtables` package. -[**It is strongly recommended that you start by reading the "Introduction to `rtables`" vignette to get familiar with the concept of `rtables`.**](https://insightsengineering.github.io/rtables/latest-tag/articles/introduction.html) +[**It is strongly recommended that you start by reading the "Introduction to `rtables`" vignette to get familiar with the concept of `rtables`.**](https://insightsengineering.github.io/rtables/latest-tag/articles/rtables.html) --------- From bb59b61d6074ef372d415b7f71a2e93b5834165c Mon Sep 17 00:00:00 2001 From: shajoezhu Date: Mon, 23 Sep 2024 12:13:23 +0800 Subject: [PATCH 3/6] update docs --- R/riskdiff.R | 2 +- R/summarize_colvars.R | 2 +- man/control_riskdiff.Rd | 2 +- man/summarize_colvars.Rd | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/R/riskdiff.R b/R/riskdiff.R index 73e0856542..1f7237c6b2 100644 --- a/R/riskdiff.R +++ b/R/riskdiff.R @@ -170,7 +170,7 @@ afun_riskdiff <- function(df, #' #' @inheritParams add_riskdiff #' @param format (`string` or `function`)\cr the format label (string) or formatting function to apply to the risk -#' difference statistic. See the `3d` string options in [list_valid_format_labels()] for possible format strings. +#' difference statistic. See the `3d` string options in [formatters::list_valid_format_labels()] for possible format strings. #' Defaults to `"xx.x (xx.x - xx.x)"`. #' #' @return A `list` of items with names corresponding to the arguments. diff --git a/R/summarize_colvars.R b/R/summarize_colvars.R index 581539a8bc..3c4f182d38 100644 --- a/R/summarize_colvars.R +++ b/R/summarize_colvars.R @@ -4,7 +4,7 @@ #' #' The analyze function [summarize_colvars()] uses the statistics function [s_summary()] to analyze variables that are #' arranged in columns. The variables to analyze should be specified in the table layout via column splits (see -#' [split_cols_by()] and [split_cols_by_multivar()]) prior to using [summarize_colvars()]. +#' [rtables::split_cols_by()] and [rtables::split_cols_by_multivar()]) prior to using [summarize_colvars()]. #' #' The function is a minimal wrapper for [rtables::analyze_colvars()], a function typically used to apply different #' analysis methods in rows for each column variable. To use the analysis methods as column labels, please refer to diff --git a/man/control_riskdiff.Rd b/man/control_riskdiff.Rd index 4466050527..60c7d9be6b 100644 --- a/man/control_riskdiff.Rd +++ b/man/control_riskdiff.Rd @@ -19,7 +19,7 @@ control_riskdiff( calculations. A new column will be added for each value of \code{arm_y}.} \item{format}{(\code{string} or \code{function})\cr the format label (string) or formatting function to apply to the risk -difference statistic. See the \verb{3d} string options in \code{\link[=list_valid_format_labels]{list_valid_format_labels()}} for possible format strings. +difference statistic. See the \verb{3d} string options in \code{\link[formatters:list_formats]{formatters::list_valid_format_labels()}} for possible format strings. Defaults to \code{"xx.x (xx.x - xx.x)"}.} \item{col_label}{(\code{character})\cr labels to use when rendering the risk difference column within the table. diff --git a/man/summarize_colvars.Rd b/man/summarize_colvars.Rd index 600c46583c..704cb0f52a 100644 --- a/man/summarize_colvars.Rd +++ b/man/summarize_colvars.Rd @@ -42,7 +42,7 @@ in columns, and add it to the table layout. The analyze function \code{\link[=summarize_colvars]{summarize_colvars()}} uses the statistics function \code{\link[=s_summary]{s_summary()}} to analyze variables that are arranged in columns. The variables to analyze should be specified in the table layout via column splits (see -\code{\link[=split_cols_by]{split_cols_by()}} and \code{\link[=split_cols_by_multivar]{split_cols_by_multivar()}}) prior to using \code{\link[=summarize_colvars]{summarize_colvars()}}. +\code{\link[rtables:split_cols_by]{rtables::split_cols_by()}} and \code{\link[rtables:split_cols_by_multivar]{rtables::split_cols_by_multivar()}}) prior to using \code{\link[=summarize_colvars]{summarize_colvars()}}. The function is a minimal wrapper for \code{\link[rtables:analyze_colvars]{rtables::analyze_colvars()}}, a function typically used to apply different analysis methods in rows for each column variable. To use the analysis methods as column labels, please refer to From 21c9977e03237706a07aabac30c8410688a76029 Mon Sep 17 00:00:00 2001 From: shajoezhu Date: Mon, 23 Sep 2024 13:02:03 +0800 Subject: [PATCH 4/6] fix lintr --- R/riskdiff.R | 4 ++-- man/control_riskdiff.Rd | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/R/riskdiff.R b/R/riskdiff.R index 1f7237c6b2..d52f6020a6 100644 --- a/R/riskdiff.R +++ b/R/riskdiff.R @@ -170,8 +170,8 @@ afun_riskdiff <- function(df, #' #' @inheritParams add_riskdiff #' @param format (`string` or `function`)\cr the format label (string) or formatting function to apply to the risk -#' difference statistic. See the `3d` string options in [formatters::list_valid_format_labels()] for possible format strings. -#' Defaults to `"xx.x (xx.x - xx.x)"`. +#' difference statistic. See the `3d` string options in [formatters::list_valid_format_labels()] for possible format +#' strings. Defaults to `"xx.x (xx.x - xx.x)"`. #' #' @return A `list` of items with names corresponding to the arguments. #' diff --git a/man/control_riskdiff.Rd b/man/control_riskdiff.Rd index 60c7d9be6b..3d9f4cecf9 100644 --- a/man/control_riskdiff.Rd +++ b/man/control_riskdiff.Rd @@ -19,8 +19,8 @@ control_riskdiff( calculations. A new column will be added for each value of \code{arm_y}.} \item{format}{(\code{string} or \code{function})\cr the format label (string) or formatting function to apply to the risk -difference statistic. See the \verb{3d} string options in \code{\link[formatters:list_formats]{formatters::list_valid_format_labels()}} for possible format strings. -Defaults to \code{"xx.x (xx.x - xx.x)"}.} +difference statistic. See the \verb{3d} string options in \code{\link[formatters:list_formats]{formatters::list_valid_format_labels()}} for possible format +strings. Defaults to \code{"xx.x (xx.x - xx.x)"}.} \item{col_label}{(\code{character})\cr labels to use when rendering the risk difference column within the table. If more than one comparison arm is specified in \code{arm_y}, default labels will specify which two arms are From 8fb59684bc5fe646160c554cf40bd0bd220849b0 Mon Sep 17 00:00:00 2001 From: Emily de la Rua Date: Mon, 23 Sep 2024 19:33:52 -0400 Subject: [PATCH 5/6] Fix n_events bug --- R/incidence_rate.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/incidence_rate.R b/R/incidence_rate.R index cb8aa0f6e1..a4d7169559 100644 --- a/R/incidence_rate.R +++ b/R/incidence_rate.R @@ -76,7 +76,7 @@ s_incidence_rate <- function(df, checkmate::assert_numeric(df[[.var]], any.missing = FALSE) checkmate::assert_integerish(df[[n_events]], any.missing = FALSE) - n_unique <- n_available(unique(df[[id_var]][df$n_events == 1])) + n_unique <- n_available(unique(df[[id_var]][df[[n_events]] == 1])) input_time_unit <- control$input_time_unit num_pt_year <- control$num_pt_year conf_level <- control$conf_level From cb513d9b0767e91b373d671afa93d316ae999bbb Mon Sep 17 00:00:00 2001 From: Emily de la Rua Date: Mon, 23 Sep 2024 19:39:03 -0400 Subject: [PATCH 6/6] Update n_events check --- R/incidence_rate.R | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/R/incidence_rate.R b/R/incidence_rate.R index a4d7169559..fd26d48656 100644 --- a/R/incidence_rate.R +++ b/R/incidence_rate.R @@ -63,10 +63,12 @@ s_incidence_rate <- function(df, id_var = "USUBJID", control = control_incidence_rate()) { if (lifecycle::is_present(is_event)) { + checkmate::assert_string(is_event) lifecycle::deprecate_warn( "0.9.6", "s_incidence_rate(is_event)", "s_incidence_rate(n_events)" ) - n_events <- as.numeric(is_event) + n_events <- is_event + df[[n_events]] <- as.numeric(df[[is_event]]) } assert_df_with_variables(df, list(tte = .var, n_events = n_events))