File: test-stat-boxplot.R

package info (click to toggle)
r-cran-ggplot2 3.4.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 8,748 kB
  • sloc: sh: 15; makefile: 5
file content (27 lines) | stat: -rw-r--r-- 872 bytes parent folder | download | duplicates (2)
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
test_that("stat_boxplot drops missing rows with a warning", {

  p1 <- ggplot(PlantGrowth, aes(x = group, y = weight)) +
    geom_boxplot(position = "dodge") +
    scale_x_discrete(limits = c("trt1", "ctrl"))

  p2 <- ggplot(PlantGrowth, aes(x = group, y = weight)) +
    geom_boxplot(position = "dodge2") +
    scale_x_discrete(limits = c("trt1", "ctrl"))

  expect_snapshot_warning(ggplot_build(p1))
  expect_snapshot_warning(ggplot_build(p2))
})

test_that("stat_boxplot can suppress warning about missing rows", {
  p1 <- ggplot(PlantGrowth, aes(x = group, y = weight)) +
    geom_boxplot(position = "dodge", na.rm = TRUE) +
    scale_x_discrete(limits = c("trt1", "ctrl"))

  expect_silent(ggplot_build(p1))
})

test_that("stat_boxplot errors with missing x/y aesthetics", {
  p <- ggplot(PlantGrowth) +
    geom_boxplot()
  expect_snapshot_error(ggplot_build(p))
})