Skip to contents

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 to c(col_est, col_moe). If spanner is NULL, columns is passed to cols_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 to cols_merge_uncert_ext(). If not NULL, spanner is passed to the label parameter of gt::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 with 0 decimal places and it would result in "2". With 4 decimal places, the formatted value becomes "2.3400". The trailing zeros can be removed with drop_trailing_zeros = TRUE. If you always need decimals = 0, the fmt_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 to locale. This setting is TRUE by default.

...

Additional parameters passed to gt::fmt_number() by fmt_acs_estimate() or to gt::fmt_percent() by fmt_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 the call argument of abort() 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()