Hide one or more columnsSource:
cols_hide() function allows us to hide one or more columns from
appearing in the final output table. While it's possible and often desirable
to omit columns from the input table data before introduction to the
function, there can be cases where the data in certain columns is useful (as
a column reference during formatting of other columns) but the final display
of those columns is not necessary.
A table object that is created using the
The column names to hide from the output display table. Values provided that do not correspond to column names will be disregarded.
The hiding of columns is internally a rendering directive, so, all columns
that are 'hidden' are still accessible and useful in any expression provided
rows argument. Furthermore, the
cols_hide() function (as with many
gt functions) can be placed anywhere in a pipeline of gt function
calls (acting as a promise to hide columns when the timing is right). However
there's perhaps greater readability when placing this call closer to the end
of such a pipeline. The
cols_hide() function quietly changes the visible
state of a column (much like the
cols_unhide() function) and doesn't yield
warnings or messages when changing the state of already-invisible columns.
countrypops to create a gt table. Hide the
country_code_3 columns with
countrypops to create a gt table. Use the
population column to
provide the conditional placement of footnotes, then hide that column and one
other. Note that the order of the
statements has no effect.