The cells_stub_grand_summary()
function
Use a portion of the countrypops
dataset to create a gt table. Add some styling to a grand summary stub cell with tab_style()
and using cells_stub_grand_summary()
in the locations
argument.
countrypops |>
dplyr:: filter (country_name == "Spain" , year < 1970 ) |>
dplyr:: select (- contains ("country" )) |>
gt (rowname_col = "year" ) |>
fmt_number (
columns = population,
decimals = 0
) |>
grand_summary_rows (
columns = population,
fns = list (change = ~ max (.) - min (.)),
fmt = ~ fmt_integer (.)
) |>
tab_style (
style = cell_text (weight = "bold" , transform = "uppercase" ),
locations = cells_stub_grand_summary (rows = "change" )
)
population
1960
30,455,000
1961
30,739,250
1962
31,023,366
1963
31,296,651
1964
31,609,195
1965
31,954,292
1966
32,283,194
1967
32,682,947
1968
33,113,134
1969
33,441,054
change
2,986,054