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

Regression with units objects #6356

Closed
agila5 opened this issue Mar 7, 2025 · 3 comments
Closed

Regression with units objects #6356

agila5 opened this issue Mar 7, 2025 · 3 comments

Comments

@agila5
Copy link

agila5 commented Mar 7, 2025

Dear all,

I think I've found a regression in the ggplot2 package when working with units objects. This is the output with the CRAN version of ggplot2:

library(ggplot2)
#> Warning: package 'ggplot2' was built under R version 4.4.3
library(units)
#> udunits database from C:/Users/andre/AppData/Local/R/win-library/4.4/units/share/udunits/udunits2.xml

toy <- data.frame(x = set_units(1:10, "m", mode = "standard"))
ggplot(toy) + 
  geom_point(aes(x = x, y = x))

Created on 2025-03-07 with reprex v2.1.1.9000

Session info
sessioninfo::session_info()
#> Warning in system2("quarto", "-V", stdout = TRUE, env = paste0("TMPDIR=", :
#> running command '"quarto"
#> TMPDIR=C:/Users/andre/AppData/Local/Temp/Rtmpq8oXKc/file4ec82b8451b4 -V' had
#> status 1
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.4.2 (2024-10-31 ucrt)
#>  os       Windows 11 x64 (build 26100)
#>  system   x86_64, mingw32
#>  ui       RTerm
#>  language (EN)
#>  collate  Italian_Italy.utf8
#>  ctype    Italian_Italy.utf8
#>  tz       Europe/Rome
#>  date     2025-03-07
#>  pandoc   3.2 @ C:/Program Files/RStudio/resources/app/bin/quarto/bin/tools/ (via rmarkdown)
#>  quarto   NA @ C:\\PROGRA~1\\RStudio\\RESOUR~1\\app\\bin\\quarto\\bin\\quarto.exe
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version    date (UTC) lib source
#>  cli           3.6.4      2025-02-13 [1] CRAN (R 4.4.3)
#>  colorspace    2.1-1      2024-07-26 [1] CRAN (R 4.4.2)
#>  curl          6.2.1      2025-02-19 [1] CRAN (R 4.4.2)
#>  digest        0.6.37     2024-08-19 [1] CRAN (R 4.4.2)
#>  dplyr         1.1.4      2023-11-17 [1] CRAN (R 4.4.2)
#>  evaluate      1.0.3      2025-01-10 [1] CRAN (R 4.4.2)
#>  farver        2.1.2      2024-05-13 [1] CRAN (R 4.4.2)
#>  fastmap       1.2.0      2024-05-15 [1] CRAN (R 4.4.2)
#>  fs            1.6.5      2024-10-30 [1] CRAN (R 4.4.2)
#>  generics      0.1.3      2022-07-05 [1] CRAN (R 4.4.2)
#>  ggplot2     * 3.5.1      2024-04-23 [1] CRAN (R 4.4.3)
#>  glue          1.8.0      2024-09-30 [1] CRAN (R 4.4.2)
#>  gtable        0.3.6      2024-10-25 [1] CRAN (R 4.4.2)
#>  htmltools     0.5.8.1    2024-04-04 [1] CRAN (R 4.4.2)
#>  knitr         1.49       2024-11-08 [1] CRAN (R 4.4.2)
#>  labeling      0.4.3      2023-08-29 [1] CRAN (R 4.4.2)
#>  lifecycle     1.0.4      2023-11-07 [1] CRAN (R 4.4.2)
#>  magrittr      2.0.3      2022-03-30 [1] CRAN (R 4.4.2)
#>  munsell       0.5.1      2024-04-01 [1] CRAN (R 4.4.2)
#>  pillar        1.10.1     2025-01-07 [1] CRAN (R 4.4.2)
#>  pkgconfig     2.0.3      2019-09-22 [1] CRAN (R 4.4.2)
#>  R6            2.5.1      2021-08-19 [1] CRAN (R 4.4.2)
#>  Rcpp          1.0.14     2025-01-12 [1] CRAN (R 4.4.2)
#>  reprex        2.1.1.9000 2025-02-25 [1] Github (tidyverse/reprex@07cd5d7)
#>  rlang         1.1.5      2025-01-17 [1] CRAN (R 4.4.2)
#>  rmarkdown     2.29       2024-11-04 [1] CRAN (R 4.4.2)
#>  rstudioapi    0.17.1     2024-10-22 [1] CRAN (R 4.4.2)
#>  scales        1.3.0      2023-11-28 [1] CRAN (R 4.4.2)
#>  sessioninfo   1.2.3      2025-02-05 [1] CRAN (R 4.4.2)
#>  tibble        3.2.1      2023-03-20 [1] CRAN (R 4.4.2)
#>  tidyselect    1.2.1      2024-03-11 [1] CRAN (R 4.4.2)
#>  units       * 0.8-6      2025-03-07 [1] Github (r-quantities/units@4d8d0c1)
#>  vctrs         0.6.5      2023-12-01 [1] CRAN (R 4.4.2)
#>  withr         3.0.2      2024-10-28 [1] CRAN (R 4.4.2)
#>  xfun          0.51.2     2025-02-20 [1] https://yihui.r-universe.dev (R 4.4.2)
#>  xml2          1.3.6      2023-12-04 [1] CRAN (R 4.4.2)
#>  yaml          2.3.10     2024-07-26 [1] CRAN (R 4.4.2)
#> 
#>  [1] C:/Users/andre/AppData/Local/R/win-library/4.4
#>  [2] C:/Program Files/R/R-4.4.2/library
#>  * ── Packages attached to the search path.
#> 
#> ──────────────────────────────────────────────────────────────────────────────

and this is what happens with the Github version:

library(ggplot2)
library(units)
#> udunits database from C:/Users/andre/AppData/Local/R/win-library/4.4/units/share/udunits/udunits2.xml

toy <- data.frame(x = set_units(1:10, "m", mode = "standard"))
ggplot(toy) + 
  geom_point(aes(x = x, y = x))
#> Error in make_title(..., self = self): unused arguments (list(), "x")

Created on 2025-03-07 with reprex v2.1.1.9000

Session info
sessioninfo::session_info()
#> Warning in system2("quarto", "-V", stdout = TRUE, env = paste0("TMPDIR=", :
#> running command '"quarto"
#> TMPDIR=C:/Users/andre/AppData/Local/Temp/RtmpYLZFVc/file496c3b055fb3 -V' had
#> status 1
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.4.2 (2024-10-31 ucrt)
#>  os       Windows 11 x64 (build 26100)
#>  system   x86_64, mingw32
#>  ui       RTerm
#>  language (EN)
#>  collate  Italian_Italy.utf8
#>  ctype    Italian_Italy.utf8
#>  tz       Europe/Rome
#>  date     2025-03-07
#>  pandoc   3.2 @ C:/Program Files/RStudio/resources/app/bin/quarto/bin/tools/ (via rmarkdown)
#>  quarto   NA @ C:\\PROGRA~1\\RStudio\\RESOUR~1\\app\\bin\\quarto\\bin\\quarto.exe
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version    date (UTC) lib source
#>  cli           3.6.4      2025-02-13 [1] CRAN (R 4.4.3)
#>  colorspace    2.1-1      2024-07-26 [1] CRAN (R 4.4.2)
#>  digest        0.6.37     2024-08-19 [1] CRAN (R 4.4.2)
#>  dplyr         1.1.4      2023-11-17 [1] CRAN (R 4.4.2)
#>  evaluate      1.0.3      2025-01-10 [1] CRAN (R 4.4.2)
#>  farver        2.1.2      2024-05-13 [1] CRAN (R 4.4.2)
#>  fastmap       1.2.0      2024-05-15 [1] CRAN (R 4.4.2)
#>  fs            1.6.5      2024-10-30 [1] CRAN (R 4.4.2)
#>  generics      0.1.3      2022-07-05 [1] CRAN (R 4.4.2)
#>  ggplot2     * 3.5.1.9000 2025-03-07 [1] Github (tidyverse/ggplot2@e727e2b)
#>  glue          1.8.0      2024-09-30 [1] CRAN (R 4.4.2)
#>  gtable        0.3.6      2024-10-25 [1] CRAN (R 4.4.2)
#>  htmltools     0.5.8.1    2024-04-04 [1] CRAN (R 4.4.2)
#>  knitr         1.49       2024-11-08 [1] CRAN (R 4.4.2)
#>  labeling      0.4.3      2023-08-29 [1] CRAN (R 4.4.2)
#>  lifecycle     1.0.4      2023-11-07 [1] CRAN (R 4.4.2)
#>  magrittr      2.0.3      2022-03-30 [1] CRAN (R 4.4.2)
#>  munsell       0.5.1      2024-04-01 [1] CRAN (R 4.4.2)
#>  pillar        1.10.1     2025-01-07 [1] CRAN (R 4.4.2)
#>  pkgconfig     2.0.3      2019-09-22 [1] CRAN (R 4.4.2)
#>  R6            2.5.1      2021-08-19 [1] CRAN (R 4.4.2)
#>  Rcpp          1.0.14     2025-01-12 [1] CRAN (R 4.4.2)
#>  reprex        2.1.1.9000 2025-02-25 [1] Github (tidyverse/reprex@07cd5d7)
#>  rlang         1.1.5      2025-01-17 [1] CRAN (R 4.4.2)
#>  rmarkdown     2.29       2024-11-04 [1] CRAN (R 4.4.2)
#>  rstudioapi    0.17.1     2024-10-22 [1] CRAN (R 4.4.2)
#>  scales        1.3.0      2023-11-28 [1] CRAN (R 4.4.2)
#>  sessioninfo   1.2.3      2025-02-05 [1] CRAN (R 4.4.2)
#>  tibble        3.2.1      2023-03-20 [1] CRAN (R 4.4.2)
#>  tidyselect    1.2.1      2024-03-11 [1] CRAN (R 4.4.2)
#>  units       * 0.8-6      2025-03-07 [1] Github (r-quantities/units@4d8d0c1)
#>  vctrs         0.6.5      2023-12-01 [1] CRAN (R 4.4.2)
#>  withr         3.0.2      2024-10-28 [1] CRAN (R 4.4.2)
#>  xfun          0.51.2     2025-02-20 [1] https://yihui.r-universe.dev (R 4.4.2)
#>  yaml          2.3.10     2024-07-26 [1] CRAN (R 4.4.2)
#> 
#>  [1] C:/Users/andre/AppData/Local/R/win-library/4.4
#>  [2] C:/Program Files/R/R-4.4.2/library
#>  * ── Packages attached to the search path.
#> 
#> ──────────────────────────────────────────────────────────────────────────────

I'm not sure whether this is a ggplot2 or units issue but, for the moment, I reported this issue only here.

@teunbrand
Copy link
Collaborator

Thanks for the report!

It seems {units} adapts the make_title() method here:

https://github.com/r-quantities/units/blob/4d8d0c1c24c1cfd7631a18502efd453beb9fa31b/R/scale_units.R#L114-L118

We adapted that method in #6200. I think that feature is valuable, implementing backwards compatibility will be gnarly and I don't think we advertise make_title() as an extension point. For these reasons I'm inclined to suggest that {units} should add a ... argument to their method.

@agila5
Copy link
Author

agila5 commented Mar 7, 2025

Thanks for your reply! I will add a twin issue in the units repo

@agila5
Copy link
Author

agila5 commented Mar 8, 2025

Fixed in r-quantities/units#401

@agila5 agila5 closed this as completed Mar 8, 2025
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

2 participants