Skip to content

Revdep: strictness of na.value type in scales #6499

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

Closed
teunbrand opened this issue Jun 11, 2025 · 0 comments · Fixed by #6500
Closed

Revdep: strictness of na.value type in scales #6499

teunbrand opened this issue Jun 11, 2025 · 0 comments · Fixed by #6500

Comments

@teunbrand
Copy link
Collaborator

Problem

This issue emerged in #6469 and affects an estimated 8 packages.
Here is a minimal reproducible example.

devtools::load_all("~/packages/ggplot2/")

ggplot(mpg, aes(displ, hwy, colour = drv)) +
  geom_point() +
  scale_colour_manual(
    values = structure(c(`4` = "blue", f = "red", r = "green"), class = "foobar"),
    na.value = "gray"
  )
#> Error in `vec_slice<-` at ggplot2/R/scale-.R:1318:7:
#> ! Can't convert `na_value` <character> to <foobar>.

Created on 2025-06-11 with reprex v2.1.1

The issue is the same as in #6474 in that {vctrs} is too strict for this usage. While #6474 fixed this in most cases, the cases remain when values is a named vector.

Solution

We should probably copy the solution of #6474 and apply it to named palettes too.

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 a pull request may close this issue.

1 participant