The cols_unhide() function

Let’s use a small portion of the countrypops dataset to create a gt table. We’ll hide the country_code_2 and country_code_3 columns with cols_hide().

tab_1 <-
  countrypops |>
  dplyr::filter(
    country_name == "Singapore",
    year %in% 2017:2021
  ) |>
  gt() |>
  cols_hide(columns = c(country_code_2, country_code_3))

tab_1
country_name year population
Singapore 2017 5612253
Singapore 2018 5638676
Singapore 2019 5703569
Singapore 2020 5685807
Singapore 2021 5453566

If the tab_1 object is provided without the code or source data to regenerate it, and, the user wants to reveal otherwise hidden columns then cols_unhide() becomes useful.

tab_1 |> cols_unhide(columns = country_code_2)
country_name country_code_2 year population
Singapore SG 2017 5612253
Singapore SG 2018 5638676
Singapore SG 2019 5703569
Singapore SG 2020 5685807
Singapore SG 2021 5453566