sub_missing {gt} | R Documentation |
Substitute missing values in the table body
Description
Wherever there is missing data (i.e., NA
values) customizable content may
present better than the standard NA
text that would otherwise appear.
sub_missing()
allows for this replacement through its missing_text
argument (where an em dash serves as the default).
Usage
sub_missing(
data,
columns = everything(),
rows = everything(),
missing_text = "---"
)
Arguments
data |
The gt table data object
This is the gt table object that is commonly created through use of the
|
columns |
Columns to target
The columns to which substitution operations are constrained. Can either
be a series of column names provided in |
rows |
Rows to target
In conjunction with |
missing_text |
Replacement text for
The text to be used in place of |
Value
An object of class gt_tbl
.
Examples
Use select columns from the exibble
dataset to create a gt table. The
NA
values in different columns (here, we are using column indices in
columns
) will be given two variations of replacement text with two separate
calls of sub_missing()
.
exibble |> dplyr::select(-row, -group) |> gt() |> sub_missing( columns = 1:2, missing_text = "missing" ) |> sub_missing( columns = 4:7, missing_text = "nothing" )

Function ID
3-31
Function Introduced
v0.6.0
(May 24, 2022)
See Also
Other data formatting functions:
data_color()
,
fmt()
,
fmt_auto()
,
fmt_bins()
,
fmt_bytes()
,
fmt_chem()
,
fmt_country()
,
fmt_currency()
,
fmt_date()
,
fmt_datetime()
,
fmt_duration()
,
fmt_email()
,
fmt_engineering()
,
fmt_flag()
,
fmt_fraction()
,
fmt_icon()
,
fmt_image()
,
fmt_index()
,
fmt_integer()
,
fmt_markdown()
,
fmt_number()
,
fmt_partsper()
,
fmt_passthrough()
,
fmt_percent()
,
fmt_roman()
,
fmt_scientific()
,
fmt_spelled_num()
,
fmt_tf()
,
fmt_time()
,
fmt_units()
,
fmt_url()
,
sub_large_vals()
,
sub_small_vals()
,
sub_values()
,
sub_zero()