fmt_acs_estimate()
formats estimate and margin of error columns for a gt
table created with ACS data. fmt_acs_percent()
does the same for the
perc_estimate and perc_moe columns calculated by join_acs_percent()
. Both
functions are used internally by gt_acs()
.
Usage
fmt_acs_estimate(
gt_object,
col_est = "estimate",
col_moe = "moe",
columns = NULL,
col_labels = "Est.",
spanner = NULL,
decimals = 0,
use_seps = TRUE,
...,
call = caller_env()
)
fmt_acs_percent(
gt_object,
col_est = "perc_estimate",
col_moe = "perc_moe",
columns = NULL,
col_labels = "% share",
spanner = NULL,
decimals = 0,
use_seps = TRUE,
...,
call = caller_env()
)
cols_label_ext(
gt_object,
columns = NULL,
col_labels = NULL,
call = caller_env()
)
Arguments
- gt_object
A gt object.
- col_est, col_moe
Column names for the estimate and margin of error values in the table data.
- columns
If
NULL
(default), columns is set toc(col_est, col_moe)
. If spanner isNULL
, columns is passed tocols_merge_uncert_ext()
and must be a length 2 character vector.- col_labels
Column name used for one or more columns passed to
cols_label_ext()
- spanner
If
NULL
, gt table is passed tocols_merge_uncert_ext()
. If notNULL
, spanner is passed to the label parameter ofgt::tab_spanner()
.- decimals
Number of decimal places
scalar<numeric|integer>(val>=0)
// default:2
This corresponds to the exact number of decimal places to use. A value such as
2.34
can, for example, be formatted with0
decimal places and it would result in"2"
. With4
decimal places, the formatted value becomes"2.3400"
. The trailing zeros can be removed withdrop_trailing_zeros = TRUE
. If you always needdecimals = 0
, thefmt_integer()
function should be considered.- use_seps
Use digit group separators
scalar<logical>
// default:TRUE
An option to use digit group separators. The type of digit group separator is set by
sep_mark
and overridden if a locale ID is provided tolocale
. This setting isTRUE
by default.- ...
Additional parameters passed to
gt::fmt_number()
byfmt_acs_estimate()
or togt::fmt_percent()
byfmt_acs_percent()
.- call
The execution environment of a currently running function, e.g.
caller_env()
. The function will be mentioned in error messages as the source of the error. See thecall
argument ofabort()
for more information.
Details
Using cols_label_ext
cols_label_ext()
is a variant on gt::cols_label()
used by
fmt_acs_estimate()
and fmt_acs_percent()
.
See also
Other gt table:
gt_acs()
,
tab_acs_source_note()