File: test-stat-boxplot.R

package info (click to toggle)
r-cran-ggplot2 3.3.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 8,184 kB
  • sloc: sh: 15; makefile: 5
file content (29 lines) | stat: -rw-r--r-- 881 bytes parent folder | download
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
context("stat_boxplot")

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_warning(
    ggplot_build(p1),
    "Removed 10 rows containing missing values \\(stat_boxplot\\)\\."
  )
  expect_warning(
    ggplot_build(p2),
    "Removed 10 rows containing missing values \\(stat_boxplot\\)\\."
  )
})

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))
})