Formatting gt summary_rows

Is it possible to use a list of formatting functions or a vector of decimals in summary_rows()?

What I have in mind is something like:

  df %>% gt() %>%
    columns = vars(Amount, UnitCost, Count),
    fns = list(Total = ~sum(.), Mean = ~mean(.)),
    # current use: formatter = fmt_currency
    formatter = list(fmt_currency, fmt_number, fmt_number),
    # current use: decimals = 2
    decimals = c(2, 2, 0)

Currently I pipeline numerous calls to summary_rows(), but the code would be more concise if a list and vector could be used within one call.

I would also like to thank the devs for making a great package based on a grammar of tables.

Unfortunately, not at this time. The summary_rows() function needs a bit of work to make it more useful (where formatting can be defined across columns, like in your example).

I'll file an issue for this work in the gt repo so it can be prioritized and tracked over time.

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.