From 918cec862faa876df60be361cbc93efb1cf24b19 Mon Sep 17 00:00:00 2001 From: RobertASmith Date: Fri, 30 Aug 2024 14:36:46 +0100 Subject: [PATCH] minor edits to examples --- R/check_PSAstability.R | 33 ++++++++++++------------ R/check_trans_probs.R | 5 ++-- R/cheers_checker.R | 6 ++--- man/check_trans_prob_mat.Rd | 5 ++-- man/find_next_vector_element.Rd | 6 ++--- man/plot_PSA_stability.Rd | 33 ++++++++++++------------ tests/testthat/test-check_PSAstability.R | 4 +-- 7 files changed, 44 insertions(+), 48 deletions(-) diff --git a/R/check_PSAstability.R b/R/check_PSAstability.R index 1c81739..f2e5c42 100644 --- a/R/check_PSAstability.R +++ b/R/check_PSAstability.R @@ -22,33 +22,32 @@ #' @importFrom tidyr pivot_longer #' #' @examples -#' -#' \dontrun{ #' # create example matrices -#' m_eff <- as.matrix(gskVEOutils::Hyperphosphatemia_PSA$e)[,1:5] -#' colnames(m_eff) <- LETTERS[1:length(colnames(m_eff))] +#' n_psa <- 10000 #' -#' m_cost <- as.matrix(gskVEOutils::Hyperphosphatemia_PSA$c)[,1:5] -#' colnames(m_cost) <- LETTERS[1:length(colnames(m_cost))] +#' m_eff <- matrix(data = runif(n = n_psa * 4, min = 0, max = 1), +#' nrow = n_psa, +#' ncol = 4, +#' dimnames = list(NULL, paste0("Strategy ", c("A", "B", "C", "D")))) #' -#' v_strategy_labels <- setNames(object = paste0("Strategy ", colnames(m_eff)), -#' nm = colnames(m_eff)) +#' m_cost <- matrix(data = runif(n = n_psa * 4, min = 5000, max = 20000), +#' nrow = n_psa, +#' ncol = 4, +#' dimnames = list(NULL, paste0("Strategy ", c("A", "B", "C", "D")))) #' #' v_strategy_colors <- setNames(object = grDevices::palette.colors(n = ncol(m_eff)), #' nm = colnames(m_eff)) #' -#' plot_PSA_stability(m_eff = m_eff[, 1:5], -#' m_cost = m_cost[, 1:5], +#' plot_PSA_stability(m_eff = m_eff, +#' m_cost = m_cost, #' lambda = 20000, #' currency_symbol = "\u0024", -#' v_strategy_labels = v_strategy_labels, +#' v_strategy_labels = colnames(m_eff), #' v_strategy_colors = v_strategy_colors, #' comparator = colnames(m_eff)[1], -#' output = "icer", -#' include_reference_line = T, -#' log_x = F) -#' -#' } # end don't run. +#' output = "inmb", +#' include_reference_line = TRUE, +#' log_x = FALSE) #' plot_PSA_stability <- function(m_eff, m_cost, @@ -59,7 +58,7 @@ plot_PSA_stability <- function(m_eff, comparator = NULL, output = "inmb", include_reference_line = T, - log_x = F) { + log_x = FALSE) { assertthat::assert_that(is.matrix(m_eff) & is.matrix(m_cost) & is.numeric(m_eff) & is.numeric(m_cost), msg = "m_eff and m_cost must be numeric matrices") diff --git a/R/check_trans_probs.R b/R/check_trans_probs.R index 0f3d860..e8138cf 100644 --- a/R/check_trans_probs.R +++ b/R/check_trans_probs.R @@ -11,7 +11,6 @@ #' @param dead_state character vector length 1 denoting dead state (e.g. "D") #' #' @examples -#' \dontrun{ #' v_hs_names <- c("H", "S", "D") #' n_hs <- length(v_hs_names) #' m_P <- matrix(data = 0, nrow = n_hs, ncol = n_hs, @@ -22,9 +21,11 @@ #' m_P["S", "H"] <- 0.5 #' diag(m_P) <- (1 - rowSums(m_P)) #' check_trans_prob_mat(m_P) +#' +#' \dontrun{ #' # introduce error #' m_P["H", "S"] <- 0.2 -#' check_trans_prob_mat(m_P, confirm_ok = T, stop_if_not = T) +#' check_trans_prob_mat(m_P, confirm_ok = TRUE, stop_if_not = TRUE) #' } #' #' @return A message indicating whether the matrix passed all the checks or a warning/error message if any check failed. diff --git a/R/cheers_checker.R b/R/cheers_checker.R index 906ae33..b2638ec 100644 --- a/R/cheers_checker.R +++ b/R/cheers_checker.R @@ -6,12 +6,10 @@ #' @return The next element of the vector after the value #' @export #' @examples -#' \dontrun{ #' find_next_vector_element(value = 5, vector = 1:10) #' find_next_vector_element(value = 5, vector = 1:4) -#' find_next_vector_element(value = 5, vector = 1:5, LTE = F) -#' find_next_vector_element(value = 5, vector = 1:5, LTE = T) -#' } +#' find_next_vector_element(value = 5, vector = 1:5, LTE = FALSE) +#' find_next_vector_element(value = 5, vector = 1:5, LTE = TRUE) #' find_next_vector_element <- function(value, vector, LTE=FALSE) { diff --git a/man/check_trans_prob_mat.Rd b/man/check_trans_prob_mat.Rd index e9453b6..31d24b3 100644 --- a/man/check_trans_prob_mat.Rd +++ b/man/check_trans_prob_mat.Rd @@ -25,7 +25,6 @@ and 1 with all rows summing to 1. If a dead state is provided, it checks that th state -> dead state probability is 1. } \examples{ -\dontrun{ v_hs_names <- c("H", "S", "D") n_hs <- length(v_hs_names) m_P <- matrix(data = 0, nrow = n_hs, ncol = n_hs, @@ -36,9 +35,11 @@ m_P["S", "D"] <- 0.1 m_P["S", "H"] <- 0.5 diag(m_P) <- (1 - rowSums(m_P)) check_trans_prob_mat(m_P) + +\dontrun{ # introduce error m_P["H", "S"] <- 0.2 -check_trans_prob_mat(m_P, confirm_ok = T, stop_if_not = T) +check_trans_prob_mat(m_P, confirm_ok = TRUE, stop_if_not = TRUE) } } diff --git a/man/find_next_vector_element.Rd b/man/find_next_vector_element.Rd index 3a2453f..62b657b 100644 --- a/man/find_next_vector_element.Rd +++ b/man/find_next_vector_element.Rd @@ -20,11 +20,9 @@ The next element of the vector after the value Find the next element of the vector after a value } \examples{ -\dontrun{ find_next_vector_element(value = 5, vector = 1:10) find_next_vector_element(value = 5, vector = 1:4) -find_next_vector_element(value = 5, vector = 1:5, LTE = F) -find_next_vector_element(value = 5, vector = 1:5, LTE = T) -} +find_next_vector_element(value = 5, vector = 1:5, LTE = FALSE) +find_next_vector_element(value = 5, vector = 1:5, LTE = TRUE) } diff --git a/man/plot_PSA_stability.Rd b/man/plot_PSA_stability.Rd index c420c5d..0ac329a 100644 --- a/man/plot_PSA_stability.Rd +++ b/man/plot_PSA_stability.Rd @@ -14,7 +14,7 @@ plot_PSA_stability( comparator = NULL, output = "inmb", include_reference_line = T, - log_x = F + log_x = FALSE ) } \arguments{ @@ -47,32 +47,31 @@ incremental cost-effectiveness ratio (ICER), incremental costs, or incremental e for different strategies compared to a specified comparator. } \examples{ - -\dontrun{ # create example matrices -m_eff <- as.matrix(gskVEOutils::Hyperphosphatemia_PSA$e)[,1:5] -colnames(m_eff) <- LETTERS[1:length(colnames(m_eff))] +n_psa <- 10000 -m_cost <- as.matrix(gskVEOutils::Hyperphosphatemia_PSA$c)[,1:5] -colnames(m_cost) <- LETTERS[1:length(colnames(m_cost))] +m_eff <- matrix(data = runif(n = n_psa * 4, min = 0, max = 1), + nrow = n_psa, + ncol = 4, + dimnames = list(NULL, paste0("Strategy ", c("A", "B", "C", "D")))) -v_strategy_labels <- setNames(object = paste0("Strategy ", colnames(m_eff)), - nm = colnames(m_eff)) +m_cost <- matrix(data = runif(n = n_psa * 4, min = 5000, max = 20000), + nrow = n_psa, + ncol = 4, + dimnames = list(NULL, paste0("Strategy ", c("A", "B", "C", "D")))) v_strategy_colors <- setNames(object = grDevices::palette.colors(n = ncol(m_eff)), nm = colnames(m_eff)) -plot_PSA_stability(m_eff = m_eff[, 1:5], - m_cost = m_cost[, 1:5], +plot_PSA_stability(m_eff = m_eff, + m_cost = m_cost, lambda = 20000, currency_symbol = "\u0024", - v_strategy_labels = v_strategy_labels, + v_strategy_labels = colnames(m_eff), v_strategy_colors = v_strategy_colors, comparator = colnames(m_eff)[1], - output = "icer", - include_reference_line = T, - log_x = F) - -} # end don't run. + output = "inmb", + include_reference_line = TRUE, + log_x = FALSE) } diff --git a/tests/testthat/test-check_PSAstability.R b/tests/testthat/test-check_PSAstability.R index aec7c0c..8b20523 100644 --- a/tests/testthat/test-check_PSAstability.R +++ b/tests/testthat/test-check_PSAstability.R @@ -49,7 +49,7 @@ test_that("plot_PSA_stability handles valid input", { comparator = colnames(m_eff)[1], output = "icer", include_reference_line = T, - log_x = F + log_x = FALSE ) }) @@ -121,7 +121,7 @@ test_that("plot_PSA_stability flags errors", { comparator = colnames(m_eff)[1], output = "icer", include_reference_line = T, - log_x = F + log_x = FALSE ) })