I am using the GT() Package to make a very simple table.
df <- data.frame(
Size = c("Small", "Medium", "Large"),
Sold = c(1000, 2000, 3000)
)
df %>%
gt() %>%
fmt_number(
columns = vars(Sold),
sep_mark = ",",
drop_trailing_zeros = T
) %>%
summary_rows(
columns = vars(Sold),
fns = list(
Total = ~sum(.))
)
However there is a -- column, I want the total to be below the size, but still being a summary row. Because I can change color and size easier.
Thank you
You can add the missing_text argument with an empty value
library(gt)
df <- data.frame(
Size = c("Small", "Medium", "Large"),
Sold = c(1000, 2000, 3000)
)
df %>%
gt() %>%
fmt_number(
columns = vars(Sold),
sep_mark = ",",
drop_trailing_zeros = T
) %>%
grand_summary_rows(
columns = vars(Sold),
fns = list(
Total = ~sum(.)),
missing_text = ' '
)