tidyverse / ggplot2

An implementation of the Grammar of Graphics in R
https://ggplot2.tidyverse.org
Other
6.39k stars 2k forks source link

`geom_rug()` does not print a warning when `na.rm = FALSE` #5905

Closed pn317 closed 3 weeks ago

pn317 commented 1 month ago

In the help file for geom_rug(), it states that missing values are removed with a warning if na.rm = FALSE.

This does not seem to be the case.

Example

library("ggplot2")

mtcars2 <- mtcars
mtcars2$mpg <- ifelse(runif(nrow(mtcars2)) < 0.2, NA, mtcars2$mpg)

ggplot(mtcars2, aes(x = wt, y = mpg)) +
  geom_point() +
  geom_rug()

In the example, a warning is generated from geom_point() but not from geom_rug().

I think this is because x and y are both optional_aes in GeomRug, but the default Geom$handle_na() only passes required_aes and non_missing_aes to remove_missing().

I will submit a pull request

teunbrand commented 3 weeks ago

Considered fixed by #5906.