Skip to content

Could the new functional way of setting labs be okay when the applicable aesthetic is not present? #6463

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

Open
davidhodge931 opened this issue May 19, 2025 · 1 comment · May be fixed by #6483
Labels
bug an unexpected problem or unintended behavior

Comments

@davidhodge931
Copy link

Useful new feature!

Noticed the new functional way of setting labs fails when the applicable aesthetic is not present. Was wondering if it could be okay with this?

This is useful for creating wrapper functions

library(tidyverse)
library(palmerpenguins)
#> 
#> Attaching package: 'palmerpenguins'
#> The following objects are masked from 'package:datasets':
#> 
#>     penguins, penguins_raw

#works
penguins |> 
  ggplot() +
  geom_histogram(aes(x = flipper_length_mm)) +
  labs(
    x = snakecase::to_sentence_case,
    y = snakecase::to_sentence_case,
  )
#> `stat_bin()` using `bins = 30`. Pick better value `binwidth`.
#> Warning: Removed 2 rows containing non-finite outside the scale range
#> (`stat_bin()`).

#fails
penguins |> 
  ggplot() +
  geom_histogram(aes(x = flipper_length_mm)) +
  labs(
    x = snakecase::to_sentence_case,
    y = snakecase::to_sentence_case,
    fill = snakecase::to_sentence_case,
  )
#> Error in "lapply(text, glue_cmd, .envir = .envir)": ! Could not evaluate cli `{}` expression: ` to_any_case(st…`.
#> Caused by error in `to_any_case(string = string, case = "sentence", sep_in = sep_in, …`:
#> ! could not find function "to_any_case"

Created on 2025-05-20 with reprex v2.1.1

@teunbrand teunbrand added the bug an unexpected problem or unintended behavior label May 28, 2025
@teunbrand
Copy link
Collaborator

This bugs out on formatting a warning message for the function labels. It should throw a warning about unused label in this case.

@teunbrand teunbrand linked a pull request May 28, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants