The cols_move_to_start() function
Use countrypops to create a gt table. With the remaining columns, move the year column to the start of the column series with cols_move_to_start().
countrypops |>
dplyr::select(-contains("code")) |>
dplyr::filter(country_name == "Mongolia") |>
tail(5) |>
gt() |>
cols_move_to_start(columns = year)
| year |
country_name |
population |
| 2017 |
Mongolia |
3096030 |
| 2018 |
Mongolia |
3163991 |
| 2019 |
Mongolia |
3232430 |
| 2020 |
Mongolia |
3294335 |
| 2021 |
Mongolia |
3347782 |
Use countrypops to create a gt table. With the remaining columns, move year and population to the start.
countrypops |>
dplyr::select(-contains("code")) |>
dplyr::filter(country_name == "Mongolia") |>
tail(5) |>
gt() |>
cols_move_to_start(columns = c(year, population))
| year |
population |
country_name |
| 2017 |
3096030 |
Mongolia |
| 2018 |
3163991 |
Mongolia |
| 2019 |
3232430 |
Mongolia |
| 2020 |
3294335 |
Mongolia |
| 2021 |
3347782 |
Mongolia |