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

Variables names with rare characters are mishandled by make_unit_label #349

Closed
Ralayax opened this issue Jun 15, 2023 · 5 comments
Closed

Comments

@Ralayax
Copy link

Ralayax commented Jun 15, 2023

Variables names with rare characters used in french plots are mishandled by make_unit_label

To reproduce

library(tidyverse)
library(units)

# Traceback
options(error = function() traceback(3)) 

# Variable name with single quote inside
a=tibble(`Volume à l'inclusion` = set_units(1:100, mL)) 

a |>
  ggplot(aes(x = `Volume à l'inclusion`)) +
  geom_density()

Apparently make_unit_label doesn't remove the quote, only whitespaces, maybe this line should be updated to remove single quotes, double quotes and apostrophes (and maybe other characters, but these definetely produce errors).

units/R/plot.R

Line 33 in 626a41d

lab <- gsub("[[:space:]]+", "~", lab)

I'm not quite sure what the function exactly does with the lab string so this might be the wrong course of action.

Have a nice day

@Enchufa2 Enchufa2 added the bug label Jun 15, 2023
@Enchufa2
Copy link
Member

Thanks for the report, we'll take a look.

@elipousson

This comment was marked as off-topic.

@Enchufa2

This comment was marked as off-topic.

@Enchufa2
Copy link
Member

Enchufa2 commented Oct 23, 2023

@Ralayax Did you test this with ggplot2 only? I see:

library(ggplot2)

data.frame(`Volume à l'inclusion` = 1:100)  |>
  ggplot(aes(x = `Volume à l'inclusion`)) +
  geom_density()
#> Error in `geom_density()`:
#> ! Problem while computing aesthetics.
#> ℹ Error occurred in the 1st layer.
#> Caused by error:
#> ! object 'Volume à l'inclusion' not found

@Enchufa2 Enchufa2 removed the bug label Oct 23, 2023
@Enchufa2
Copy link
Member

Closing here, please feel free to reopen if the issue persists when this is fixed in ggplot2.

@Enchufa2 Enchufa2 closed this as not planned Won't fix, can't repro, duplicate, stale Oct 23, 2023
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

No branches or pull requests

3 participants