1context("stat_boxplot")
2
3test_that("stat_boxplot drops missing rows with a warning", {
4
5  p1 <- ggplot(PlantGrowth, aes(x = group, y = weight)) +
6    geom_boxplot(position = "dodge") +
7    scale_x_discrete(limits = c("trt1", "ctrl"))
8
9  p2 <- ggplot(PlantGrowth, aes(x = group, y = weight)) +
10    geom_boxplot(position = "dodge2") +
11    scale_x_discrete(limits = c("trt1", "ctrl"))
12
13  expect_warning(
14    ggplot_build(p1),
15    "Removed 10 rows containing missing values \\(stat_boxplot\\)\\."
16  )
17  expect_warning(
18    ggplot_build(p2),
19    "Removed 10 rows containing missing values \\(stat_boxplot\\)\\."
20  )
21})
22
23test_that("stat_boxplot can suppress warning about missing rows", {
24  p1 <- ggplot(PlantGrowth, aes(x = group, y = weight)) +
25    geom_boxplot(position = "dodge", na.rm = TRUE) +
26    scale_x_discrete(limits = c("trt1", "ctrl"))
27
28  expect_silent(ggplot_build(p1))
29})
30