From 46cb2d4b90676b5838452bd2f2c09538755d8f1d Mon Sep 17 00:00:00 2001 From: Melkiades Date: Thu, 9 Feb 2023 12:05:58 +0100 Subject: [PATCH 1/6] seeing the warnings maybe --- tests/testthat/test-g_lineplot.R | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tests/testthat/test-g_lineplot.R diff --git a/tests/testthat/test-g_lineplot.R b/tests/testthat/test-g_lineplot.R new file mode 100644 index 0000000000..c3cc03e7fc --- /dev/null +++ b/tests/testthat/test-g_lineplot.R @@ -0,0 +1,23 @@ +adsl <- tern_ex_adsl +adlb <- tern_ex_adlb %>% dplyr::filter(ANL01FL == "Y", PARAMCD == "ALT", AVISIT != "SCREENING") +adlb$AVISIT <- droplevels(adlb$AVISIT) +adlb <- dplyr::mutate(adlb, AVISIT = forcats::fct_reorder(AVISIT, AVISITN, min)) + +testthat::test_that("g_lineplot works with default settings", { + g_lineplot(adlb, adsl) +}) + +testthat::test_that("g_lineplot works with custom settings and statistics table", { + g_lineplot( + adlb, + adsl, + strata = control_lineplot_vars(strata = NULL), + mid = "median", + table = c("n", "mean", "mean_ci"), + control = control_summarize_vars(conf_level = 0.80), + title = "Plot of Mean and 80% Confidence Limits by Visit", + y_lab = "Lab Test", + subtitle = "Laboratory Test:", + caption = "caption" + ) +}) From 658ad9adc6a7192d77e94d9ed75a0eeca37a70a1 Mon Sep 17 00:00:00 2001 From: Melkiades Date: Thu, 9 Feb 2023 12:36:14 +0100 Subject: [PATCH 2/6] capturing it --- tests/testthat/test-g_lineplot.R | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/testthat/test-g_lineplot.R b/tests/testthat/test-g_lineplot.R index c3cc03e7fc..90bb454760 100644 --- a/tests/testthat/test-g_lineplot.R +++ b/tests/testthat/test-g_lineplot.R @@ -4,11 +4,14 @@ adlb$AVISIT <- droplevels(adlb$AVISIT) adlb <- dplyr::mutate(adlb, AVISIT = forcats::fct_reorder(AVISIT, AVISITN, min)) testthat::test_that("g_lineplot works with default settings", { - g_lineplot(adlb, adsl) + some_warning <- capture_warnings(g_lineplot(adlb, adsl)) + if (isTRUE(length(some_warning) > 0)){ + stop("THIS IS THE WARNING 1: ", some_warning) + } }) testthat::test_that("g_lineplot works with custom settings and statistics table", { - g_lineplot( + some_warning <- capture_warnings(g_lineplot( adlb, adsl, strata = control_lineplot_vars(strata = NULL), @@ -19,5 +22,8 @@ testthat::test_that("g_lineplot works with custom settings and statistics table" y_lab = "Lab Test", subtitle = "Laboratory Test:", caption = "caption" - ) + )) + if (isTRUE(length(some_warning) > 0)){ + stop("THIS IS THE WARNING 2: ", some_warning) + } }) From 59be9ce31b9938f31002e23a27cc0a67e958700b Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 9 Feb 2023 11:38:47 +0000 Subject: [PATCH 3/6] [skip actions] Restyle files --- tests/testthat/test-g_lineplot.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/testthat/test-g_lineplot.R b/tests/testthat/test-g_lineplot.R index 90bb454760..9a329c039c 100644 --- a/tests/testthat/test-g_lineplot.R +++ b/tests/testthat/test-g_lineplot.R @@ -5,7 +5,7 @@ adlb <- dplyr::mutate(adlb, AVISIT = forcats::fct_reorder(AVISIT, AVISITN, min)) testthat::test_that("g_lineplot works with default settings", { some_warning <- capture_warnings(g_lineplot(adlb, adsl)) - if (isTRUE(length(some_warning) > 0)){ + if (isTRUE(length(some_warning) > 0)) { stop("THIS IS THE WARNING 1: ", some_warning) } }) @@ -23,7 +23,7 @@ testthat::test_that("g_lineplot works with custom settings and statistics table" subtitle = "Laboratory Test:", caption = "caption" )) - if (isTRUE(length(some_warning) > 0)){ + if (isTRUE(length(some_warning) > 0)) { stop("THIS IS THE WARNING 2: ", some_warning) } }) From 79014bd5c49bf9e7abbfed6dca6ea0c36ecd7f03 Mon Sep 17 00:00:00 2001 From: Melkiades Date: Thu, 9 Feb 2023 14:44:35 +0100 Subject: [PATCH 4/6] phantom change --- tests/testthat/test-g_lineplot.R | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/testthat/test-g_lineplot.R b/tests/testthat/test-g_lineplot.R index 9a329c039c..36207a77ba 100644 --- a/tests/testthat/test-g_lineplot.R +++ b/tests/testthat/test-g_lineplot.R @@ -23,6 +23,7 @@ testthat::test_that("g_lineplot works with custom settings and statistics table" subtitle = "Laboratory Test:", caption = "caption" )) + # phantom change if (isTRUE(length(some_warning) > 0)) { stop("THIS IS THE WARNING 2: ", some_warning) } From 280f242a07a1dfeb784847ea27d83ff7f8b8d13b Mon Sep 17 00:00:00 2001 From: Melkiades Date: Thu, 9 Feb 2023 15:09:52 +0100 Subject: [PATCH 5/6] the fix --- R/g_lineplot.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/g_lineplot.R b/R/g_lineplot.R index 3347e9e726..e7bfebc28b 100644 --- a/R/g_lineplot.R +++ b/R/g_lineplot.R @@ -216,7 +216,7 @@ g_lineplot <- function(df, # nolint df_grp <- tidyr::expand(df, NULL, .data[[x]]) } df_grp <- df_grp %>% - dplyr::full_join(y = df[, c(strata, x, y)], by = c(strata, x)) %>% + dplyr::full_join(y = df[, c(strata, x, y)], by = c(strata, x), multiple = "all") %>% dplyr::group_by_at(c(strata, x)) df_stats <- df_grp %>% From 1903f72958ee1f65ffa4d1494e6ab5f20fc19af5 Mon Sep 17 00:00:00 2001 From: Melkiades Date: Thu, 9 Feb 2023 16:28:52 +0100 Subject: [PATCH 6/6] refix --- tests/testthat/test-g_lineplot.R | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/tests/testthat/test-g_lineplot.R b/tests/testthat/test-g_lineplot.R index 36207a77ba..7091cd11d1 100644 --- a/tests/testthat/test-g_lineplot.R +++ b/tests/testthat/test-g_lineplot.R @@ -4,14 +4,11 @@ adlb$AVISIT <- droplevels(adlb$AVISIT) adlb <- dplyr::mutate(adlb, AVISIT = forcats::fct_reorder(AVISIT, AVISITN, min)) testthat::test_that("g_lineplot works with default settings", { - some_warning <- capture_warnings(g_lineplot(adlb, adsl)) - if (isTRUE(length(some_warning) > 0)) { - stop("THIS IS THE WARNING 1: ", some_warning) - } + testthat::expect_silent(g_lineplot(adlb, adsl)) }) testthat::test_that("g_lineplot works with custom settings and statistics table", { - some_warning <- capture_warnings(g_lineplot( + testthat::expect_silent(g_lineplot( adlb, adsl, strata = control_lineplot_vars(strata = NULL), @@ -23,8 +20,4 @@ testthat::test_that("g_lineplot works with custom settings and statistics table" subtitle = "Laboratory Test:", caption = "caption" )) - # phantom change - if (isTRUE(length(some_warning) > 0)) { - stop("THIS IS THE WARNING 2: ", some_warning) - } })