The cols_move() function

Use the countrypops dataset to create a gt table. We’ll choose to position the population column after the country_name column by using the cols_move() function.

countrypops |>
  dplyr::select(-contains("code")) |>
  dplyr::filter(
    country_name == "Japan",
    year %in% 2012:2021
  ) |>
  gt() |>
  cols_move(
    columns = population,
    after = country_name
  ) |>
  fmt_integer(columns = population)
country_name population year
Japan 127,629,000 2012
Japan 127,445,000 2013
Japan 127,276,000 2014
Japan 127,141,000 2015
Japan 127,076,000 2016
Japan 126,972,000 2017
Japan 126,811,000 2018
Japan 126,633,000 2019
Japan 126,261,000 2020
Japan 125,681,593 2021