Skip to content

Swap vec_in() for %in% - #5606

Merged
teunbrand merged 1 commit into
tidyverse:rc/3.5.0from
teunbrand:less_strict_types
Dec 22, 2023
Merged

teunbrand merged 1 commit into
tidyverse:rc/3.5.0from
teunbrand:less_strict_types

Conversation

@teunbrand

@teunbrand teunbrand commented Dec 21, 2023 •

Copy link
Copy Markdown
Collaborator

This PR to the RC aims to fix a bug uncovered in revdepchecks affecting ~19 packages.

One such example is this:
https://github.com/tidyverse/ggplot2/blob/rc/3.5.0/revdep/problems.md#newly-broken-119

Briefly, vec_in() is too strict in that it cannot compare incompatible vectors, like logical and character vectors.
To reproduce this error, combine a logical and character level for the same aesthetic.
The fix is to replace vec_in() with %in%.

library(ggplot2) # RC branch

ggplot(mpg, aes(displ, hwy)) +
  geom_point(aes(colour = hwy > 30)) +
  geom_line(aes(colour = "foo"))
#> Error in `vec_in()` at ggplot2/R/guide-legend.R:727:5:
#> ! Can't combine <character> and <logical>.

How it should work:

devtools::load_all("~/packages/ggplot2") # This PR
#> ℹ Loading ggplot2

ggplot(mpg, aes(displ, hwy)) +
  geom_point(aes(colour = hwy > 30)) +
  geom_line(aes(colour = "foo"))

Created on 2023-12-21 with reprex v2.0.2

@thomasp85 thomasp85 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but please don't use the default windows graphic device 😛

@teunbrand

Copy link
Copy Markdown
Collaborator Author

But how else am I going to see all them aliased pixels 😱

@teunbrand
teunbrand merged commit 1b142f9 into tidyverse:rc/3.5.0 Dec 22, 2023
@teunbrand
teunbrand deleted the less_strict_types branch December 22, 2023 08:58
thomasp85 pushed a commit that referenced this pull request Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants