Skip to content

Commit

Permalink
Use na.rm parameter in StatBoxplot (#3556)
Browse files Browse the repository at this point in the history
  • Loading branch information
karawoo authored Oct 7, 2019
1 parent 1895864 commit a2ab197
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion R/stat-boxplot.r
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ StatBoxplot <- ggproto("StatBoxplot", Stat,
data$x <- data$x %||% 0
data <- remove_missing(
data,
na.rm = FALSE,
na.rm = params$na.rm,
vars = "x",
name = "stat_boxplot"
)
Expand Down
8 changes: 8 additions & 0 deletions tests/testthat/test-stat-boxplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,11 @@ test_that("stat_boxplot drops missing rows with a warning", {
"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))
})

0 comments on commit a2ab197

Please sign in to comment.