Skip to content

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

Closed
@davidhodge931

Description

@davidhodge931

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions