There are a few issues with summary_rows() that make it difficult to use. This issue will lay out some of the biggest problems with it.
One of the most confusing parts of summary_rows() is the groups argument. Its default of NULL results in the formation of grand summary rows, which is surprising since there is a dedicated function for that grand_summary_rows(). Many functions that have a groups argument now allow tidyselect semantics (cells_summary(), cells_stub_summary(), cells_row_groups()) but summary_rows() requires a precise vector a group ID values.
Using groups = TRUE to mean all groups is something that was deprecated in gt v0.3 but lives on here.
There's another issue (will be filed separately, but related): cells_summary() seems to not work with its defaults. Here's an MRE:
library(gt)
# MRE for `cells_summary()` not working
gtcars %>%
gt(rowname_col = "model", groupname_col = "mfr") %>%
summary_rows(
groups = c("Ford", "Ferrari"),
columns = year,
fns = list(`latest year` = ~ max(.)),
formatter = fmt_number,
decimals = 0,
use_seps = FALSE
) %>%
tab_style(
style = list(
cell_fill(color = background_color),
cell_text(color = text_color)
),
locations = cells_summary(groups = everything()) # default for `groups`
)
Error: `everything()` must be used within a *selecting* function.
ℹ See <https://tidyselect.r-lib.org/reference/faq-selection-context.html>.
Run `rlang::last_error()` to see where the error occurred.
This should just style all available summary rows (less the stub parts of them).
There are a few issues with
summary_rows()that make it difficult to use. This issue will lay out some of the biggest problems with it.One of the most confusing parts of
summary_rows()is thegroupsargument. Its default ofNULLresults in the formation of grand summary rows, which is surprising since there is a dedicated function for thatgrand_summary_rows(). Many functions that have agroupsargument now allow tidyselect semantics (cells_summary(),cells_stub_summary(),cells_row_groups()) butsummary_rows()requires a precise vector a group ID values.Using
groups = TRUEto mean all groups is something that was deprecated in gt v0.3 but lives on here.There's another issue (will be filed separately, but related):
cells_summary()seems to not work with its defaults. Here's an MRE:This should just style all available summary rows (less the stub parts of them).