Closed salim-b closed 5 months ago
Thanks for the bug report here. I absolutely agree that if there are no groups at build time, summary_rows()
should just act as grand_summary_rows()
does.
We ended up just improving the error message. It is better to use grand_summary_rows()
. Any usage where summary_rows()
is better than grand_summary_rows()
?
Any usage where
summary_rows()
is better thangrand_summary_rows()
?
No, I don't think so. I just thought the original error message was really not user-friendly and when I looked closer I saw that grand_summary_rows()
is just a wrapper around summary_rows(groups = ":GRAND_SUMMARY:")
...
We ended up just improving the error message.
Totally fine with me, thanks. 🙂
Prework
Description
See the error message.
Reproducible example
Created on 2023-04-04 with reprex v2.0.2
Expected result
I'd expect the above expression to return the same as
gt::grand_summary_rows(fns = "sum")
Reprex:
``` r mtcars |> dplyr::select(gear) |> gt::gt(rownames_to_stub = TRUE) |> gt::grand_summary_rows(fns = "sum") ```Workaround
One can set
groups
to the undocumented sentinel":GRAND_SUMMARY:"
:Reprex:
``` r mtcars |> dplyr::select(gear) |> gt::gt(rownames_to_stub = TRUE) |> gt::summary_rows(fns = "sum", groups = ":GRAND_SUMMARY:") ```Session info
Session info
``` r sessioninfo::session_info() #> ─ Session info ─────────────────────────────────────────────────────────────── #> setting value #> version R version 4.2.3 (2023-03-15) #> os Ubuntu 22.04.2 LTS #> system x86_64, linux-gnu #> ui X11 #> language en_US.utf8 #> collate en_US.utf8 #> ctype en_US.utf8 #> tz Europe/Zurich #> date 2023-04-04 #> pandoc 3.1.2 @ /usr/bin/ (via rmarkdown) #> #> ─ Packages ─────────────────────────────────────────────────────────────────── #> package * version date (UTC) lib source #> cli 3.6.1 2023-03-23 [1] RSPM (R 4.2.0) #> digest 0.6.31 2022-12-11 [1] RSPM (R 4.2.0) #> dplyr 1.1.1 2023-03-22 [1] CRAN (R 4.2.3) #> evaluate 0.20 2023-01-17 [1] RSPM (R 4.2.0) #> fansi 1.0.4 2023-01-22 [1] RSPM (R 4.2.0) #> fastmap 1.1.1 2023-02-24 [1] RSPM (R 4.2.0) #> fs 1.6.1 2023-02-06 [1] RSPM (R 4.2.0) #> generics 0.1.3 2022-07-05 [1] RSPM (R 4.2.0) #> glue 1.6.2 2022-02-24 [1] RSPM (R 4.2.0) #> gt 0.9.0 2023-03-31 [1] RSPM (R 4.2.0) #> htmltools 0.5.5 2023-03-23 [1] RSPM (R 4.2.0) #> knitr 1.42 2023-01-25 [1] RSPM (R 4.2.0) #> lifecycle 1.0.3 2022-10-07 [1] RSPM (R 4.2.0) #> magrittr 2.0.3 2022-03-30 [1] RSPM (R 4.2.0) #> pillar 1.9.0 2023-03-22 [1] RSPM (R 4.2.0) #> pkgconfig 2.0.3 2019-09-22 [1] RSPM (R 4.2.0) #> purrr 1.0.1 2023-01-10 [1] RSPM (R 4.2.0) #> R.cache 0.16.0 2022-07-21 [1] RSPM (R 4.2.0) #> R.methodsS3 1.8.2 2022-06-13 [1] RSPM (R 4.2.0) #> R.oo 1.25.0 2022-06-12 [1] RSPM (R 4.2.0) #> R.utils 2.12.2 2022-11-11 [1] RSPM (R 4.2.0) #> R6 2.5.1 2021-08-19 [1] RSPM (R 4.2.0) #> reprex 2.0.2 2022-08-17 [1] RSPM (R 4.2.0) #> rlang 1.1.0 2023-03-14 [1] RSPM (R 4.2.0) #> rmarkdown 2.21 2023-03-26 [1] RSPM (R 4.2.0) #> rstudioapi 0.14 2022-08-22 [1] RSPM (R 4.2.0) #> sessioninfo 1.2.2 2021-12-06 [1] RSPM (R 4.2.0) #> styler 1.9.1 2023-03-04 [1] RSPM (R 4.2.0) #> tibble 3.2.1 2023-03-20 [1] RSPM (R 4.2.0) #> tidyselect 1.2.0 2022-10-10 [1] RSPM (R 4.2.0) #> utf8 1.2.3 2023-01-31 [1] RSPM (R 4.2.0) #> vctrs 0.6.1 2023-03-22 [1] RSPM (R 4.2.0) #> withr 2.5.0 2022-03-03 [1] RSPM (R 4.2.0) #> xfun 0.38 2023-03-24 [1] RSPM (R 4.2.0) #> xml2 1.3.3 2021-11-30 [1] RSPM (R 4.2.0) #> yaml 2.3.7 2023-01-23 [1] RSPM (R 4.2.0) #> #> [1] /home/salim/.software/managed/r #> [2] /usr/local/lib/R/site-library #> [3] /usr/lib/R/site-library #> [4] /usr/lib/R/library #> #> ────────────────────────────────────────────────────────────────────────────── ```