Skip to content
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

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

Closed
pn317 opened this issue May 23, 2024 · 1 comment
Closed

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

pn317 opened this issue May 23, 2024 · 1 comment
Labels
messages requests for improvements to error, warning, or feedback messages

Comments

@pn317
Copy link
Contributor

pn317 commented May 23, 2024

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 teunbrand added the messages requests for improvements to error, warning, or feedback messages label May 31, 2024
teunbrand pushed a commit that referenced this issue Jun 6, 2024
* 'geom_rug()' prints a warning when 'na.rm = FALSE'

Fixes issue #5905.
When presented with missing values, 'geom_rug()' was not printing a
warning message, contrary to the documentation.
A warning message is now printed when 'na.rm = FALSE' ad suppressed when
'na.rm = TRUE', as expected.

* Impement local changes in 'handle_na()'

Make local changes in 'handle_na() instead of global changes to 'GeomRug'

* Test for 'geom_rug()' warning about missing values

Also added the issue number to NEWS

* Handle rugs in orthogonal directions better

When plotting rugs in both the 'x' and 'y' direction simultaneously,
values of 'x' were being dropped when 'y' was missing, and vice versa.
A warning will be given for each axis ('x' or 'y') that contains missing
values, if 'na.rm = FALSE'.

* Remove dependence on 'dplyr'

Use 'vctrs::vec_set_union()' instead of 'dplyr::union()'

* Update 'testthat' version to 3.1.5

* Add github handle to NEWS bullet
@teunbrand
Copy link
Collaborator

Considered fixed by #5906.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
messages requests for improvements to error, warning, or feedback messages
Projects
None yet
Development

No branches or pull requests

2 participants