forked from insightsengineering/tern
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-g_lineplot.R
44 lines (39 loc) · 1.51 KB
/
test-g_lineplot.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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 <- g_lineplot(adlb, adsl)
vdiffr::expect_doppelganger(title = "g_lineplot", fig = g_lineplot)
})
testthat::test_that("g_lineplot works with custom settings and statistics table", {
g_lineplot_w_stats <- g_lineplot(
adlb,
adsl,
group_var = control_lineplot_vars(group_var = NULL),
mid = "median",
table = c("n", "mean", "mean_ci"),
control = control_analyze_vars(conf_level = 0.80),
title = "Plot of Mean and 80% Confidence Limits by Visit",
x_lab = "Time",
y_lab = "Lab Test",
subtitle = "Laboratory Test:",
caption = "caption"
)
vdiffr::expect_doppelganger(title = "g_lineplot_w_stats", fig = g_lineplot_w_stats)
})
testthat::test_that("g_lineplot works with cohort_id specified", {
g_lineplot_cohorts <- g_lineplot(
adlb,
adsl,
group_var = control_lineplot_vars(group_var = "ARM", subject_var = "USUBJID"),
mid = "median",
table = c("n", "mean", "mean_ci"),
control = control_analyze_vars(conf_level = 0.80),
title = "Plot of Mean and 80% Confidence Limits by Visit",
y_lab = "Lab Test",
subtitle = "Laboratory Test:",
caption = "caption"
)
vdiffr::expect_doppelganger(title = "g_lineplot_cohorts", fig = g_lineplot_cohorts)
})