The cols_move_to_end() function

Use countrypops to create a gt table. With the remaining columns, move the year column to the end of the column series with the cols_move_to_end() function.

countrypops |>
  dplyr::select(-contains("code")) |>
  dplyr::filter(country_name == "Mongolia") |>
  tail(5) |>
  gt() |>
  cols_move_to_end(columns = year)
country_name population year
Mongolia 3096030 2017
Mongolia 3163991 2018
Mongolia 3232430 2019
Mongolia 3294335 2020
Mongolia 3347782 2021

Use countrypops to create a gt table. With the remaining columns, move year and country_name to the end of the column series.

countrypops |>
  dplyr::select(-contains("code")) |>
  dplyr::filter(country_name == "Mongolia") |>
  tail(5) |>
  gt() |>
  cols_move_to_end(columns = c(year, country_name))
population year country_name
3096030 2017 Mongolia
3163991 2018 Mongolia
3232430 2019 Mongolia
3294335 2020 Mongolia
3347782 2021 Mongolia