Skip to content

Use na.rm parameter in StatBoxplot #3556

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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))
})