The cols_align() function

Let’s use countrypops to create a small gt table. We can change the alignment of the population column with cols_align(). In this example, the label and body cells of population will be aligned to the left.

countrypops |>
  dplyr::select(-contains("code")) |>
  dplyr::filter(
    country_name == "San Marino",
    year %in% 2017:2021
  ) |>
  gt(
    rowname_col = "year",
    groupname_col = "country_name"
  ) |>
  cols_align(
    align = "left",
    columns = population
  )
population
San Marino
2017 34056
2018 34156
2019 34178
2020 34007
2021 33745