jthomasmock / gtExtras

A Collection of Helper Functions for the gt Package.
https://jthomasmock.github.io/gtExtras/
Other
193 stars 26 forks source link

`gt_plt_summary` fails to generate plot for some integer columns #128

Open LinusLach opened 4 months ago

LinusLach commented 4 months ago

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.

jthomasmock commented 1 month ago

I have this partially resolved locally. Looks like there is an upstream issue in scales: https://github.com/r-lib/scales/issues/413