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 %>% diff --git a/tests/testthat/test-g_lineplot.R b/tests/testthat/test-g_lineplot.R new file mode 100644 index 0000000000..7091cd11d1 --- /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", { + testthat::expect_silent(g_lineplot(adlb, adsl)) +}) + +testthat::test_that("g_lineplot works with custom settings and statistics table", { + testthat::expect_silent(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" + )) +})