`gt_plt_summary` fails to generate plot for some integer columns
Description
A classic case of "it doesn't run on my machine": I am trying to generate a simple summary plot using the generic palmerpenguins dataset which has worked in the past, but somehow doesn't work anymore for certain columns. Removing the columns body_mass_g and year generates a plot with loads of warnings but including these columns leads to errors.
Reproducible example
Here, an error is returned.
library(palmerpenguins)
library(gtExtras)
library(tidyverse)
penguins %>% gt_plt_summary()
#> Warning in geom_point(data = NULL, aes(x = rng_vals[1], y = 1), color = "transparent", : All aesthetics have length 1, but the data has 342 rows.
#> ℹ Please consider using `annotate()` or provide this layer with data containing
#> a single row.
#> Warning in geom_point(data = NULL, aes(x = rng_vals[2], y = 1), color = "transparent", : All aesthetics have length 1, but the data has 342 rows.
#> ℹ Please consider using `annotate()` or provide this layer with data containing
#> a single row.
#> Warning in geom_point(data = NULL, aes(x = rng_vals[1], y = 1), color = "transparent", : All aesthetics have length 1, but the data has 342 rows.
#> ℹ Please consider using `annotate()` or provide this layer with data containing
#> a single row.
#> Warning in geom_point(data = NULL, aes(x = rng_vals[2], y = 1), color = "transparent", : All aesthetics have length 1, but the data has 342 rows.
#> ℹ Please consider using `annotate()` or provide this layer with data containing
#> a single row.
#> Warning in geom_point(data = NULL, aes(x = rng_vals[1], y = 1), color = "transparent", : All aesthetics have length 1, but the data has 342 rows.
#> ℹ Please consider using `annotate()` or provide this layer with data containing
#> a single row.
#> Warning in geom_point(data = NULL, aes(x = rng_vals[2], y = 1), color = "transparent", : All aesthetics have length 1, but the data has 342 rows.
#> ℹ Please consider using `annotate()` or provide this layer with data containing
#> a single row.
#> Error in break_suffix[bad_break][improved_break & !power10_break] <- names(lower_break[improved_break & : NAs nicht zugelassen in Teilbereichszuweisungen
Created on 2024-05-13 with reprex v2.1.0
The code snippet below generates warnings but no errors.
library(palmerpenguins)
library(gtExtras)
#> Lade nötiges Paket: gt
library(tidyverse)
penguins %>%
select(-c(body_mass_g,year)) %>%
gt_plt_summary()
#> Warning in geom_point(data = NULL, aes(x = rng_vals[1], y = 1), color = "transparent", : All aesthetics have length 1, but the data has 342 rows.
#> ℹ Please consider using `annotate()` or provide this layer with data containing
#> a single row.
#> Warning in geom_point(data = NULL, aes(x = rng_vals[2], y = 1), color = "transparent", : All aesthetics have length 1, but the data has 342 rows.
#> ℹ Please consider using `annotate()` or provide this layer with data containing
#> a single row.
#> Warning in geom_point(data = NULL, aes(x = rng_vals[1], y = 1), color = "transparent", : All aesthetics have length 1, but the data has 342 rows.
#> ℹ Please consider using `annotate()` or provide this layer with data containing
#> a single row.
#> Warning in geom_point(data = NULL, aes(x = rng_vals[2], y = 1), color = "transparent", : All aesthetics have length 1, but the data has 342 rows.
#> ℹ Please consider using `annotate()` or provide this layer with data containing
#> a single row.
#> Warning in geom_point(data = NULL, aes(x = rng_vals[1], y = 1), color = "transparent", : All aesthetics have length 1, but the data has 342 rows.
#> ℹ Please consider using `annotate()` or provide this layer with data containing
#> a single row.
#> Warning in geom_point(data = NULL, aes(x = rng_vals[2], y = 1), color = "transparent", : All aesthetics have length 1, but the data has 342 rows.
#> ℹ Please consider using `annotate()` or provide this layer with data containing
#> a single row.
Created on 2024-05-13 with reprex v2.1.0
Session Info
sessionInfo()
#> R version 4.4.0 (2024-04-24 ucrt)
#> Platform: x86_64-w64-mingw32/x64
#> Running under: Windows 10 x64 (build 19045)
#>
#> Matrix products: default
#>
#>
#> locale:
#> [1] LC_COLLATE=German_Germany.utf8 LC_CTYPE=German_Germany.utf8
#> [3] LC_MONETARY=German_Germany.utf8 LC_NUMERIC=C
#> [5] LC_TIME=German_Germany.utf8
#>
#> time zone: Europe/Berlin
#> tzcode source: internal
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] lubridate_1.9.3 forcats_1.0.0 stringr_1.5.1
#> [4] dplyr_1.1.4 purrr_1.0.2 readr_2.1.5
#> [7] tidyr_1.3.1 tibble_3.2.1 ggplot2_3.5.1
#> [10] tidyverse_2.0.0 gtExtras_0.5.0 gt_0.10.1
#> [13] palmerpenguins_0.1.1
#>
#> loaded via a namespace (and not attached):
#> [1] styler_1.10.3 utf8_1.2.4 generics_0.1.3 xml2_1.3.6
#> [5] stringi_1.8.4 hms_1.1.3 digest_0.6.35 magrittr_2.0.3
#> [9] timechange_0.3.0 evaluate_0.23 grid_4.4.0 fastmap_1.1.1
#> [13] R.oo_1.26.0 R.cache_0.16.0 R.utils_2.12.3 rematch2_2.1.2
#> [17] fansi_1.0.6 scales_1.3.0 cli_3.6.2 rlang_1.1.3
#> [21] R.methodsS3_1.8.2 munsell_0.5.1 reprex_2.1.0 withr_3.0.0
#> [25] yaml_2.3.8 tools_4.4.0 tzdb_0.4.0 colorspace_2.1-0
#> [29] paletteer_1.6.0 vctrs_0.6.5 R6_2.5.1 lifecycle_1.0.4
#> [33] fs_1.6.4 fontawesome_0.5.2 pkgconfig_2.0.3 pillar_1.9.0
#> [37] gtable_0.3.5 glue_1.7.0 xfun_0.43 tidyselect_1.2.1
#> [41] rstudioapi_0.16.0 knitr_1.46 htmltools_0.5.8.1 rmarkdown_2.26
#> [45] compiler_4.4.0
Created on 2024-05-13 with reprex v2.1.0
Any help is appreciated! PS: I obviously tried reinstalling all the packages and even updating to R 4.4.0 didn't seem to solve the issue.
I have this partially resolved locally. Looks like there is an upstream issue in scales: https://github.com/r-lib/scales/issues/413
Hi there, Thank you for this very interesting package!
Seems like the issue in r-lib/scales is resolved, but even if I download the dev version of scales and gtExtras, I can still reproduce the error. Interestingly, numeric columns with "enough" range are working.
data.frame(
x1 = c(rep(2020, 4), rep(2021, 8), rep(2022, 10))
) |>
gt_plt_summary()
Error in break_suffix[bad_break][improved_break & !power10_break] <- names(lower_break[improved_break & :
NAs interdits dans les affectations indicées
But, if I change the first value from 2020 to 202, it works.
data.frame(
x1 = c(rep(202, 4), rep(2021, 8), rep(2022, 10))
) |>
gt_plt_summary()
Any idea when that bug could be fixed?
sessionInfo()
R version 4.4.1 (2024-06-14 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 10 x64 (build 19045)
Matrix products: default
locale:
[1] LC_COLLATE=French_France.utf8 LC_CTYPE=French_France.utf8 LC_MONETARY=French_France.utf8 LC_NUMERIC=C
[5] LC_TIME=French_France.utf8
time zone: Europe/Paris
tzcode source: internal
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] openxlsx_4.2.7.1 here_1.0.1 lubridate_1.9.3 forcats_1.0.0 stringr_1.5.1 dplyr_1.1.4 purrr_1.0.2
[8] readr_2.1.5 tidyr_1.3.1 tibble_3.2.1 tidyverse_2.0.0 ggplot2_3.5.1 gtExtras_0.5.0.9005 gt_0.11.1
loaded via a namespace (and not attached):
[1] gtable_0.3.6 xfun_0.48 remotes_2.5.0 processx_3.8.4 lattice_0.22-6 callr_3.7.6 paletteer_1.6.0 tzdb_0.4.0
[9] vctrs_0.6.5 tools_4.4.1 ps_1.8.0 generics_0.1.3 curl_5.2.3 fansi_1.0.6 pkgconfig_2.0.3 desc_1.4.3
[17] lifecycle_1.0.4 compiler_4.4.1 farver_2.1.2 textshaping_0.4.0 munsell_0.5.1 fontawesome_0.5.2 htmltools_0.5.8.1 sass_0.4.9
[25] yaml_2.3.10 pillar_1.9.0 zip_2.3.1 tidyselect_1.2.1 digest_0.6.37 stringi_1.8.4 rematch2_2.1.2 labeling_0.4.3
[33] rprojroot_2.0.4 fastmap_1.2.0 grid_4.4.1 colorspace_2.1-1 cli_3.6.3 magrittr_2.0.3 pkgbuild_1.4.4 utf8_1.2.4
[41] withr_3.0.2 scales_1.3.0.9000 timechange_0.3.0 rmarkdown_2.29 ragg_1.3.3 zoo_1.8-12 hms_1.1.3 evaluate_1.0.1
[49] knitr_1.48 rlang_1.1.4 Rcpp_1.0.13 glue_1.8.0 xml2_1.3.6 svglite_2.1.3 rstudioapi_0.17.1 R6_2.5.1
[57] systemfonts_1.1.0