Skip to content

Commit a2ab197

Browse files
authored
Use na.rm parameter in StatBoxplot (#3556)
1 parent 1895864 commit a2ab197

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

R/stat-boxplot.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ StatBoxplot <- ggproto("StatBoxplot", Stat,
5151
data$x <- data$x %||% 0
5252
data <- remove_missing(
5353
data,
54-
na.rm = FALSE,
54+
na.rm = params$na.rm,
5555
vars = "x",
5656
name = "stat_boxplot"
5757
)

tests/testthat/test-stat-boxplot.R

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,11 @@ test_that("stat_boxplot drops missing rows with a warning", {
1919
"Removed 10 rows containing missing values \\(stat_boxplot\\)\\."
2020
)
2121
})
22+
23+
test_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+
})

0 commit comments

Comments
 (0)