From 38326aa4b353bbdc0e9101bc45e7903724797874 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 5 Dec 2024 00:10:07 +0800 Subject: [PATCH] fix error of unconfirmed BOR calculation --- R/onco_resp.R | 2 +- man/sfreq.Rd | 34 ++++++++++++++++++++++----------- tests/testthat/test-onco_resp.R | 8 ++++---- 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/R/onco_resp.R b/R/onco_resp.R index a2f15b4..c57bc2b 100644 --- a/R/onco_resp.R +++ b/R/onco_resp.R @@ -177,7 +177,7 @@ derive_bor <- function(data, TRUE ~ AVALC ) ) %>% - left_join(aval_map, by = c("AVALC" = "avalc_temp")) %>% + left_join(aval_map, by = "avalc_temp") %>% mutate(AVAL = .data$aval_temp) %>% arrange(!!sym(unique_id), AVAL, ADT) %>% # select the best and first one as the best overall response. diff --git a/man/sfreq.Rd b/man/sfreq.Rd index 38c7be7..760b00c 100644 --- a/man/sfreq.Rd +++ b/man/sfreq.Rd @@ -43,24 +43,36 @@ h_count_sort(data, df, sort_var, row_tot, nested_row = FALSE, .order = NULL) \item{data}{(\code{data.frame})\cr a data frame that contains the variables to be summarized and grouped.} -\item{var}{(\code{vector})\cr a character vector of variables to be summarized within \code{data}.} +\item{var}{(\code{string})\cr a character variable to be summarized within \code{data}.} + +\item{nested_vars}{(\code{string})\cr a character variable as the nested level to +be summarized along with \code{var}.} \item{by}{(\code{string})\cr a character variable for grouping within \code{data}.} -\item{denom}{(\code{data.frame})\cr the denominator to use for the percentage, but -not use temporarily. By default, it's NULL, meaning the function will use -the number of values of the \code{data}, including missing value.} +\item{fmt}{(\code{string})\cr formatting string from \code{formatters::list_valid_format_labels()} +for frequency counts and percentages.} + +\item{denom}{(\code{numeric} or \code{data.frame})\cr denominator for proportion can be a +numeric vector of denominators or a data frame where we can count the \code{var} inside.} + +\item{distinct}{(\code{string})\cr a character variable to determine which level should +be kept only unique rows from \code{data}. Default is 'USUBJID' for normal counting, but +it can be set as 'STUDYID' for AE events if necessary.} \item{fctdrop}{(\code{logical})\cr whether to include the levels of the variables but with no records.} -\item{na_str}{(\code{string})\cr a string to replace \code{NA} in the output if no records -will be counted for any category.} +\item{col_tot}{(\code{logical})\cr whether to add total column in the output or not.} -\item{format}{(\code{string})\cr formatting string from \code{formatters::list_valid_format_labels()} -for frequency counts and percentages.} +\item{row_tot}{(\code{string})\cr Default set as NULL for no total row, but if set as +'n' or other words that will be defined as a label for total row.} -\item{addtot}{(\code{logical})\cr whether to add total column in the output or not.} +\item{nested_row}{(\code{logical})\cr whether to add nested variable in the label row. +Set to TRUE for AE counting.} + +\item{na_str}{(\code{string})\cr a string to replace \code{NA} in the output if no records +will be counted for any category, but not used.} } \value{ A object \code{Desc} contains an intermediate data with long form for @@ -69,8 +81,8 @@ post-processing and final data with wide form for presentation. \description{ \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} -Create a summary table for one or more variables by one group, as well as a -total column if necessary. +Create a summary table for one variable or nested variable by one group, as +well as a total column if necessary. } \section{Functions}{ \itemize{ diff --git a/tests/testthat/test-onco_resp.R b/tests/testthat/test-onco_resp.R index 7b932dd..fbb3fe5 100644 --- a/tests/testthat/test-onco_resp.R +++ b/tests/testthat/test-onco_resp.R @@ -33,7 +33,7 @@ test_that("derive_bor works as expected with default arguments", { ) %>% select(-TRTSDTC) - res <- derive_bor(data = adrs) + res <- suppressWarnings(derive_bor(data = adrs)) expect_tibble(res) expect_identical( res, @@ -91,7 +91,7 @@ test_that("derive_bor works as expected for confirmed BOR", { ) %>% select(-TRTSDTC) - res <- derive_bor(data = adrs, confirm = TRUE) + res <- suppressWarnings(derive_bor(data = adrs, confirm = TRUE)) expect_identical( res, tibble::tibble( @@ -148,7 +148,7 @@ test_that("derive_bor works as expected with zero NE", { ) %>% select(-TRTSDTC) - res <- derive_bor(data = adrs, max_ne = 0, confirm = TRUE) + res <- suppressWarnings(derive_bor(data = adrs, max_ne = 0, confirm = TRUE)) expect_identical( res, tibble::tibble( @@ -206,7 +206,7 @@ test_that("derive_bor works as expected with at least 56 days of reference inter ) %>% select(-TRTSDTC) - res <- derive_bor(data = adrs, ref_start_window = 56, ref_interval = 56, confirm = TRUE) + res <- suppressWarnings(derive_bor(data = adrs, ref_start_window = 56, ref_interval = 56, confirm = TRUE)) expect_identical( res, tibble::tibble(