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

info_time_style() not working #1124

Closed
AlbertRapp opened this issue Nov 13, 2022 · 6 comments
Closed

info_time_style() not working #1124

AlbertRapp opened this issue Nov 13, 2022 · 6 comments

Comments

@AlbertRapp
Copy link

Description

The info_time_style() function is not working. Not a biggie. The info can be found in the docs of fmt_time(). But I thought I'd document the error.

Reproducible example

gt::info_time_style()
#> Error in gsub(pattern, replacement, x, fixed = fixed): invalid 'replacement' argument

Created on 2022-11-13 with reprex v2.0.2

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.2.2 (2022-10-31)
#>  os       Ubuntu 20.04.5 LTS
#>  system   x86_64, linux-gnu
#>  ui       X11
#>  language (EN)
#>  collate  en_US.UTF-8
#>  ctype    en_US.UTF-8
#>  tz       Europe/Berlin
#>  date     2022-11-13
#>  pandoc   2.19.2 @ /usr/lib/rstudio/bin/quarto/bin/tools/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  ! package     * version    date (UTC) lib source
#>  P assertthat    0.2.1      2019-03-21 [?] CRAN (R 4.0.0)
#>    bigD          0.2.0      2022-09-05 [1] CRAN (R 4.2.2)
#>  P cli           3.4.1      2022-09-23 [?] CRAN (R 4.2.1)
#>  P colorspace    2.0-3      2022-02-21 [?] CRAN (R 4.1.2)
#>  P DBI           1.1.3      2022-06-18 [?] CRAN (R 4.2.1)
#>  P digest        0.6.30     2022-10-18 [?] CRAN (R 4.2.1)
#>  P dplyr         1.0.10     2022-09-01 [?] CRAN (R 4.2.1)
#>  P evaluate      0.18       2022-11-07 [?] CRAN (R 4.2.2)
#>  P fansi         1.0.3      2022-03-24 [?] CRAN (R 4.1.3)
#>  P fastmap       1.1.0      2021-01-25 [?] CRAN (R 4.0.3)
#>  P fs            1.5.2      2021-12-08 [?] CRAN (R 4.1.2)
#>  P generics      0.1.3      2022-07-05 [?] CRAN (R 4.2.1)
#>  P ggplot2       3.4.0      2022-11-04 [?] CRAN (R 4.2.2)
#>  P glue          1.6.2      2022-02-24 [?] CRAN (R 4.1.2)
#>    gt            0.7.0.9000 2022-11-11 [1] Github (rstudio/gt@a4e108c)
#>  P gtable        0.3.1      2022-09-01 [?] CRAN (R 4.2.1)
#>  P highr         0.9        2021-04-16 [?] CRAN (R 4.0.5)
#>  P htmltools     0.5.3      2022-07-18 [?] CRAN (R 4.2.1)
#>  P knitr         1.40       2022-08-24 [?] CRAN (R 4.2.1)
#>  P lifecycle     1.0.3      2022-10-07 [?] CRAN (R 4.2.1)
#>  P magrittr      2.0.3      2022-03-30 [?] CRAN (R 4.1.3)
#>  P munsell       0.5.0      2018-06-12 [?] CRAN (R 4.0.0)
#>  P pillar        1.8.1      2022-08-19 [?] CRAN (R 4.2.1)
#>  P pkgconfig     2.0.3      2019-09-22 [?] CRAN (R 4.0.0)
#>  P R6            2.5.1      2021-08-19 [?] CRAN (R 4.1.1)
#>  P reprex        2.0.2      2022-08-17 [?] CRAN (R 4.2.1)
#>  P rlang         1.0.6      2022-09-24 [?] CRAN (R 4.2.1)
#>  P rmarkdown     2.18       2022-11-09 [?] CRAN (R 4.2.2)
#>  P rstudioapi    0.14       2022-08-22 [?] CRAN (R 4.2.1)
#>  P scales        1.2.1      2022-08-20 [?] CRAN (R 4.2.1)
#>  P sessioninfo   1.2.2      2021-12-06 [?] CRAN (R 4.2.1)
#>  P stringi       1.7.8      2022-07-11 [?] CRAN (R 4.2.1)
#>  P stringr       1.4.1.9000 2022-11-09 [?] Github (tidyverse/stringr@f482fb0)
#>  P tibble        3.1.8      2022-07-22 [?] CRAN (R 4.2.1)
#>  P tidyselect    1.2.0      2022-10-10 [?] CRAN (R 4.2.1)
#>  P utf8          1.2.2      2021-07-24 [?] CRAN (R 4.1.0)
#>  P vctrs         0.5.0.9000 2022-11-09 [?] Github (r-lib/vctrs@ece04d3)
#>  P withr         2.5.0      2022-03-03 [?] CRAN (R 4.1.3)
#>  P xfun          0.34       2022-10-18 [?] CRAN (R 4.2.2)
#>  P yaml          2.3.6      2022-10-18 [?] CRAN (R 4.2.1)
#> 
#>  [1] /media/albert/Files/NextCloud/R Projects/gt_book/renv/library/R-4.2/x86_64-pc-linux-gnu
#>  [2] /usr/lib/R/library
#> 
#>  P ── Loaded and on-disk path mismatch.
#> 
#> ──────────────────────────────────────────────────────────────────────────────

Expected result

Similar output as info_date_style().

@AlbertRapp
Copy link
Author

I've just got the same error on the fmt_time() now. But it seems that not all time formats are affected (I think mostly the AM/PM formats.)

gt::exibble |> 
  dplyr::select(time) |> 
  gt::gt() |> 
  gt::fmt_time(columns = 'time', time_style =   "hms")
#> Error in gsub(pattern, replacement, x, fixed = fixed): invalid 'replacement' argument

Created on 2022-11-13 with reprex v2.0.2

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.2.2 (2022-10-31)
#>  os       Ubuntu 20.04.5 LTS
#>  system   x86_64, linux-gnu
#>  ui       X11
#>  language (EN)
#>  collate  en_US.UTF-8
#>  ctype    en_US.UTF-8
#>  tz       Europe/Berlin
#>  date     2022-11-13
#>  pandoc   2.19.2 @ /usr/lib/rstudio/bin/quarto/bin/tools/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  ! package     * version    date (UTC) lib source
#>  P assertthat    0.2.1      2019-03-21 [?] CRAN (R 4.0.0)
#>    bigD          0.2.0      2022-09-05 [1] CRAN (R 4.2.2)
#>  P cli           3.4.1      2022-09-23 [?] CRAN (R 4.2.1)
#>  P colorspace    2.0-3      2022-02-21 [?] CRAN (R 4.1.2)
#>  P DBI           1.1.3      2022-06-18 [?] CRAN (R 4.2.1)
#>  P digest        0.6.30     2022-10-18 [?] CRAN (R 4.2.1)
#>  P dplyr         1.0.10     2022-09-01 [?] CRAN (R 4.2.1)
#>  P evaluate      0.18       2022-11-07 [?] CRAN (R 4.2.2)
#>  P fansi         1.0.3      2022-03-24 [?] CRAN (R 4.1.3)
#>  P fastmap       1.1.0      2021-01-25 [?] CRAN (R 4.0.3)
#>  P fs            1.5.2      2021-12-08 [?] CRAN (R 4.1.2)
#>  P generics      0.1.3      2022-07-05 [?] CRAN (R 4.2.1)
#>  P ggplot2       3.4.0      2022-11-04 [?] CRAN (R 4.2.2)
#>  P glue          1.6.2      2022-02-24 [?] CRAN (R 4.1.2)
#>    gt            0.7.0.9000 2022-11-11 [1] Github (rstudio/gt@a4e108c)
#>  P gtable        0.3.1      2022-09-01 [?] CRAN (R 4.2.1)
#>  P highr         0.9        2021-04-16 [?] CRAN (R 4.0.5)
#>  P htmltools     0.5.3      2022-07-18 [?] CRAN (R 4.2.1)
#>  P knitr         1.40       2022-08-24 [?] CRAN (R 4.2.1)
#>  P lifecycle     1.0.3      2022-10-07 [?] CRAN (R 4.2.1)
#>  P magrittr      2.0.3      2022-03-30 [?] CRAN (R 4.1.3)
#>  P munsell       0.5.0      2018-06-12 [?] CRAN (R 4.0.0)
#>  P pillar        1.8.1      2022-08-19 [?] CRAN (R 4.2.1)
#>  P pkgconfig     2.0.3      2019-09-22 [?] CRAN (R 4.0.0)
#>  P R6            2.5.1      2021-08-19 [?] CRAN (R 4.1.1)
#>  P reprex        2.0.2      2022-08-17 [?] CRAN (R 4.2.1)
#>  P rlang         1.0.6      2022-09-24 [?] CRAN (R 4.2.1)
#>  P rmarkdown     2.18       2022-11-09 [?] CRAN (R 4.2.2)
#>  P rstudioapi    0.14       2022-08-22 [?] CRAN (R 4.2.1)
#>  P scales        1.2.1      2022-08-20 [?] CRAN (R 4.2.1)
#>  P sessioninfo   1.2.2      2021-12-06 [?] CRAN (R 4.2.1)
#>  P stringi       1.7.8      2022-07-11 [?] CRAN (R 4.2.1)
#>  P stringr       1.4.1.9000 2022-11-09 [?] Github (tidyverse/stringr@f482fb0)
#>  P tibble        3.1.8      2022-07-22 [?] CRAN (R 4.2.1)
#>  P tidyselect    1.2.0      2022-10-10 [?] CRAN (R 4.2.1)
#>  P utf8          1.2.2      2021-07-24 [?] CRAN (R 4.1.0)
#>  P vctrs         0.5.0.9000 2022-11-09 [?] Github (r-lib/vctrs@ece04d3)
#>  P withr         2.5.0      2022-03-03 [?] CRAN (R 4.1.3)
#>  P xfun          0.34       2022-10-18 [?] CRAN (R 4.2.2)
#>  P yaml          2.3.6      2022-10-18 [?] CRAN (R 4.2.1)
#> 
#>  [1] /media/albert/Files/NextCloud/R Projects/gt_book/renv/library/R-4.2/x86_64-pc-linux-gnu
#>  [2] /usr/lib/R/library
#> 
#>  P ── Loaded and on-disk path mismatch.
#> 
#> ──────────────────────────────────────────────────────────────────────────────

@rich-iannone
Copy link
Member

Thanks for reporting this bug! Could you test with the dev version of bigD on GitHub? I’ve got a feeling that some recent work on that package has solved for that particular error.

If that does solve it, I will get an update of bigD out on CRAN right before the gt update. Thanks again for finding all these bugs and filing issues!

@AlbertRapp
Copy link
Author

I ran devtools::install_github("rich-iannone/bigD") but this did not fix the issue.

@rich-iannone
Copy link
Member

I could not reproduce the error with several installations of R on different platforms and with different library installs of gt and bigD (CRAN and GitHub). Because of that, I can’t fix the bug.

Would it be possible for you to do some more investigation to determine how this bug arises?

@AlbertRapp
Copy link
Author

It seems this problem is only present in my {renv}-controlled {gt} book Quarto project. In other {renv}-controlled projects I do not have this issue. So this may or may not be linked to {renv}. In any case, here's how I can reconstruct this behavior.

  1. Create new {renv}-controlled project
  2. Install CRAN-version of {gt}
  3. Test gt::info_time_style(). Works at this stage.
  4. Install {devtools}, and dev version of {gt}. (This installs {V8}, {bigD}, {juicyjuice} and then {gt})
  5. Test gt::info_time_style(). Still works at this stage.
  6. Restart R session
  7. Test gt::info_time_style(). This does not work anymore and prints the gsub() error. Reinstalling any of the aforementioned packages does not solve this.

I've also restarted the R session after the CRAN {gt} and {devtools} install. Everything works fine after restart. To me that's pretty weird behavior. Any ideas what goes wrong?

@rich-iannone
Copy link
Member

Thanks for providing the details here, this is really helpful! I have a pretty good idea where the problem lies but I am unsure how renv exposes it. However, now I have a better means to replicate the error and can potentially work on a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

2 participants