# NOT RUN {
# Use `countrypops` to create a gt table; add
# some styling to a grand summary cell with
# with `tab_style()` and `cells_grand_summary()`
tab_1 <-
countrypops %>%
dplyr::filter(
country_name == "Spain",
year < 1970
) %>%
dplyr::select(-contains("country")) %>%
gt(rowname_col = "year") %>%
fmt_number(
columns = vars(population),
decimals = 0
) %>%
grand_summary_rows(
columns = vars(population),
fns = list(
change = ~max(.) - min(.)
),
formatter = fmt_number,
decimals = 0
) %>%
tab_style(
style = list(
cell_text(style = "italic"),
cell_fill(color = "lightblue")
),
locations = cells_grand_summary(
columns = vars(population),
rows = 1)
)
# }
Run the code above in your browser using DataLab