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

No partial matching in theme subsetting #5522

Merged
merged 3 commits into from
Nov 28, 2023

Conversation

teunbrand
Copy link
Collaborator

This PR aims to fix #2724. It supersedes #5335.

Briefly, it implements #2724 (comment) by using .subset2() as the dollar-subsetting method for themes.

Quick demo:

library(ggplot2)

# Old problematic behaviour
t <- theme(foobar = 12)
t$foo
#> [1] 12
t$foobar
#> [1] 12

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

# New correct behaviour
t$foo
#> NULL
t$foobar
#> [1] 12

Created on 2023-11-14 with reprex v2.0.2

@teunbrand teunbrand changed the title Theme partial match No partial matching in theme subsetting Nov 14, 2023
@teunbrand teunbrand added this to the ggplot2 3.5.0 milestone Nov 21, 2023
R/theme.R Outdated Show resolved Hide resolved
Co-authored-by: Thomas Lin Pedersen <thomasp85@gmail.com>
Copy link
Member

@thomasp85 thomasp85 left a comment

Choose a reason for hiding this comment

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

LGTM

@teunbrand teunbrand merged commit 5f518d0 into tidyverse:main Nov 28, 2023
12 checks passed
@teunbrand teunbrand deleted the theme_partial_match branch November 28, 2023 08:17
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.

R partial string matching can have unexpected results when theme elements are missing
2 participants