rows_unhide() allows us to take one or more hidden rows (usually done
via rows_hide()) and make them visible in the final output table. This may
be important in cases where the user obtains a gt_tbl object with hidden
rows and there is motivation to reveal one or more of those.
Arguments
- data
The gt table data object
obj:<gt_tbl>// requiredThis is the gt table object that is commonly created through use of the
gt()function.- rows
Rows to target
<row-targeting expression>// default:everything()The rows to unhide in the output display table. Can either be a series of row IDs provided in
c(), a vector of row indices, or a select helper function (e.g.starts_with(),ends_with(),contains(),matches(),num_range(), andeverything()). We can also use expressions to filter down to the rows we need (e.g.,[column_1] > 100 & [column_2] < 50).
Details
The hiding and unhiding of rows is internally a rendering directive, so, all
rows that are 'hidden' are still accessible and useful in any expression
provided to a columns argument. The rows_unhide() function quietly
changes the visible state of a row (much like the rows_hide() function) and
doesn't yield warnings or messages when changing the state of already-visible
rows.
Examples
Let's use a small portion of the countrypops dataset to create a gt
table. We'll hide all rows but then unhide specific ones.
tab_1 <-
countrypops |>
dplyr::filter(
country_name == "Japan",
year %in% 2017:2021
) |>
gt(rowname_col = "year") |>
fmt_integer(columns = population) |>
rows_hide(rows = everything())
tab_1
If we obtain the tab_1 object without access to the code or source data,
and we want to reveal otherwise hidden rows, then rows_unhide() becomes
useful.
tab_1 |> rows_unhide(rows = c("2019", "2021"))
See also
Other row addition/modification functions:
grand_summary_rows(),
row_group_order(),
row_order(),
rows_add(),
rows_hide(),
summary_columns(),
summary_rows()