jthomasmock / gtExtras

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

gt_plt_bullet fails with "unable to load shared object '/usr/lib/R/site-library/svglite/libs/svglite.so" #59

Closed sanjmeh closed 2 years ago

sanjmeh commented 2 years ago

Prework

I searched the error and did following recommended steps but it did not solve the problem.

Description

The vignette example of gt_plt_bullet fails to run on my machine, and gives following error.

Error in dyn.load(file, DLLpath = DLLpath, ...) : 
  unable to load shared object '/usr/lib/R/site-library/svglite/libs/svglite.so':
  /usr/lib/R/site-library/svglite/libs/svglite.so: undefined symbol: R_GE_clipPathFillRule

I have R installed on Ubuntu 20 server.

Reproducible example

library(pacman)
p_load(reprex,gt,gtExtras,janitor,magrittr)
set.seed(37)
  tibble::rownames_to_column(mtcars) %>%
  dplyr::select(rowname, cyl:drat, mpg) %>%
  dplyr::group_by(cyl) %>%
  dplyr::mutate(target_col = mean(mpg)) %>%
  dplyr::slice_sample(n = 3) %>%
  dplyr::ungroup() %>%
  gt::gt() %>%
  gt_plt_bullet(column = mpg, target = target_col, width = 45)
#> Error in dyn.load(file, DLLpath = DLLpath, ...): unable to load shared object '/usr/lib/R/site-library/svglite/libs/svglite.so':
#>   /usr/lib/R/site-library/svglite/libs/svglite.so: undefined symbol: R_GE_clipPathFillRule

Expected result

Screenshot 2022-07-07 at 8 16 33 PM

Session info

sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.1.2 (2021-11-01)
#>  os       Ubuntu 20.04.4 LTS
#>  system   x86_64, linux-gnu
#>  ui       X11
#>  language (EN)
#>  collate  C.UTF-8
#>  ctype    C.UTF-8
#>  tz       Asia/Kolkata
#>  date     2022-07-07
#>  pandoc   2.17.1.1 @ /usr/lib/rstudio-server/bin/quarto/bin/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version    date (UTC) lib source
#>  assertthat    0.2.1      2019-03-21 [3] CRAN (R 4.0.0)
#>  backports     1.4.1      2021-12-13 [3] CRAN (R 4.1.2)
#>  checkmate     2.1.0      2022-04-21 [1] RSPM (R 4.1.2)
#>  cli           3.3.0      2022-04-25 [3] CRAN (R 4.2.0)
#>  colorspace    2.0-3      2022-02-21 [3] CRAN (R 4.1.2)
#>  crayon        1.5.1      2022-03-26 [1] RSPM (R 4.1.2)
#>  DBI           1.1.2      2021-12-20 [3] CRAN (R 4.1.2)
#>  digest        0.6.29     2021-12-01 [3] CRAN (R 4.1.2)
#>  dplyr         1.0.9      2022-04-28 [3] CRAN (R 4.2.0)
#>  ellipsis      0.3.2      2021-04-29 [3] CRAN (R 4.0.5)
#>  evaluate      0.15       2022-02-18 [3] CRAN (R 4.1.2)
#>  fansi         1.0.3      2022-03-24 [3] CRAN (R 4.1.3)
#>  fastmap       1.1.0      2021-01-25 [3] CRAN (R 4.0.3)
#>  fontawesome   0.2.2      2021-07-02 [3] CRAN (R 4.1.1)
#>  fs            1.5.2      2021-12-08 [3] CRAN (R 4.1.2)
#>  generics      0.1.3      2022-07-05 [1] RSPM (R 4.1.2)
#>  ggplot2       3.3.6      2022-05-03 [3] CRAN (R 4.2.0)
#>  glue          1.6.2      2022-02-24 [3] CRAN (R 4.1.2)
#>  gt          * 0.6.0      2022-05-24 [1] RSPM (R 4.1.2)
#>  gtable        0.3.0      2019-03-25 [3] CRAN (R 4.0.0)
#>  gtExtras    * 0.4.0.9005 2022-07-07 [1] Github (jthomasmock/gtExtras@fb83dd8)
#>  highr         0.9        2021-04-16 [3] CRAN (R 4.0.5)
#>  htmltools     0.5.2      2021-08-25 [3] CRAN (R 4.1.1)
#>  janitor     * 2.1.0      2021-01-05 [3] CRAN (R 4.0.3)
#>  knitr         1.39       2022-04-26 [3] CRAN (R 4.2.0)
#>  lifecycle     1.0.1      2021-09-24 [3] CRAN (R 4.1.1)
#>  lubridate     1.8.0      2021-10-07 [3] CRAN (R 4.1.1)
#>  magrittr    * 2.0.3      2022-03-30 [1] RSPM (R 4.1.2)
#>  munsell       0.5.0      2018-06-12 [3] CRAN (R 4.0.0)
#>  pacman      * 0.5.1      2019-03-11 [1] RSPM (R 4.1.2)
#>  paletteer     1.4.0      2021-07-20 [1] RSPM (R 4.1.2)
#>  pillar        1.7.0      2022-02-01 [3] CRAN (R 4.1.2)
#>  pkgconfig     2.0.3      2019-09-22 [3] CRAN (R 4.0.0)
#>  purrr         0.3.4      2020-04-17 [3] CRAN (R 4.0.0)
#>  R.cache       0.15.0     2021-04-30 [1] RSPM (R 4.1.2)
#>  R.methodsS3   1.8.1      2020-08-26 [1] RSPM (R 4.1.2)
#>  R.oo          1.24.0     2020-08-26 [1] RSPM (R 4.1.2)
#>  R.utils       2.11.0     2021-09-26 [1] RSPM (R 4.1.2)
#>  R6            2.5.1      2021-08-19 [3] CRAN (R 4.1.1)
#>  rematch2      2.1.2      2020-05-01 [3] CRAN (R 4.0.0)
#>  reprex      * 2.0.1      2021-08-05 [3] CRAN (R 4.1.0)
#>  rlang         1.0.3      2022-06-27 [1] RSPM (R 4.1.2)
#>  rmarkdown     2.14       2022-04-25 [3] CRAN (R 4.2.0)
#>  rstudioapi    0.13       2020-11-12 [3] CRAN (R 4.0.3)
#>  scales        1.2.0      2022-04-13 [3] CRAN (R 4.1.3)
#>  sessioninfo   1.2.2      2021-12-06 [3] CRAN (R 4.1.2)
#>  snakecase     0.11.0     2019-05-25 [3] CRAN (R 4.0.0)
#>  stringi       1.7.6      2021-11-29 [1] RSPM (R 4.1.2)
#>  stringr       1.4.0      2019-02-10 [3] CRAN (R 4.0.0)
#>  styler        1.7.0      2022-03-13 [1] RSPM (R 4.1.2)
#>  systemfonts   1.0.4      2022-02-11 [3] CRAN (R 4.1.2)
#>  tibble        3.1.7      2022-05-03 [3] CRAN (R 4.2.0)
#>  tidyselect    1.1.2      2022-02-21 [3] CRAN (R 4.1.2)
#>  utf8          1.2.2      2021-07-24 [3] CRAN (R 4.1.0)
#>  vctrs         0.4.1      2022-04-13 [3] CRAN (R 4.1.3)
#>  withr         2.5.0      2022-03-03 [1] RSPM (R 4.1.2)
#>  xfun          0.31       2022-05-10 [3] CRAN (R 4.2.0)
#>  yaml          2.3.5      2022-02-21 [3] CRAN (R 4.1.2)
#> 
#>  [1] /home/sanjay/R/x86_64-pc-linux-gnu-library/4.1
#>  [2] /usr/local/lib/R/site-library
#>  [3] /usr/lib/R/site-library
#>  [4] /usr/lib/R/library
#> 
#> ──────────────────────────────────────────────────────────────────────────────

jthomasmock commented 2 years ago

Howdy!

Can you try installing svglite binary from RStudio Package Manager rather than from source?

https://packagemanager.rstudio.com/client/#/repos/1/packages/svglite

You're getting a general svglite installation/compilation issue.

sanjmeh commented 2 years ago

I installed svglite as advised above using install.packages('svglite', type = 'source') but the error persisists. And after posting the above, I see a larger issue in most of gtExtras functions failing. I tried a few and get the following errors,

gt_sparkline

mtcars %>%
    dplyr::group_by(cyl) %>%
    # must end up with list of data for each row in the input dataframe
    dplyr::summarize(mpg_data = list(mpg), .groups = "drop") |> gt() |> gt_sparkline()

Error: lazy-load database '/home/sanjay/R/x86_64-pc-linux-gnu-library/4.1/gtExtras/R/gtExtras.rdb' is corrupt In addition: Warning messages: 1: restarting interrupted promise evaluation 2: internal error -3 in R_decompress1

gt_duplicate_column

plyr::tibble(x = c(seq(1.2e6, 2e6, length.out = 5))) %>%
+     gt::gt() %>%
+     gt_duplicate_column(x,dupe_name = "point_plot")

Error in dplyr::tibble(x = c(seq(1200000, 2e+06, length.out = 5))) %>% : lazy-load database '/home/sanjay/R/x86_64-pc-linux-gnu-library/4.1/gtExtras/R/gtExtras.rdb' is corrupt

Many functions are giving the gtExtras.rdb is corrupt error

sanjmeh commented 2 years ago

Oh, restarting R set things right. I am so sorry I didn;t restart R before raising the issue here. I will close this in a few hours if I donot get the same error again.

jthomasmock commented 2 years ago

Glad to hear it was resolved! In general if you're getting "corrupt" errors like that it's a good idea to restart R and install fresh.

Also especially on Linux try installing from our free Package Manager rather than from source, it will be faster and less error prone.

https://packagemanager.rstudio.com/client/#/repos/1/packages/gtExtras

jthomasmock commented 2 years ago

Closing for now - sounds like it has been resolved. Thanks!