Skip to contents

cols_merge_uncert_ext() is a variant of gt::cols_merge_uncert() to support col_val and col_uncert to be set based on a length 2 cols parameter and optionally apply a prefix or postfix value. These options are primarily for internal use by gt_acs(), fmt_acs_estimate(), and fmt_acs_percent().

Usage

cols_merge_uncert_ext(
  gt_object,
  columns = NULL,
  col_val = NULL,
  col_uncert = NULL,
  prefix = "",
  postfix = "",
  sep = "",
  ...,
  call = caller_env()
)

Arguments

gt_object

A gt object.

columns

description

col_val

Column to target for base values

<column-targeting expression> // required

The column that contains values for the start of the range. While select helper functions such as starts_with() and ends_with() can be used for column targeting, it's recommended that a single column name be used. This is to ensure that exactly one column is provided here.

col_uncert

Column or columns to target for uncertainty values

<column-targeting expression> // required

The most common case involves supplying a single column with uncertainties; these values will be combined with those in col_val. Less commonly, the lower and upper uncertainty bounds may be different. For that case, two columns representing the lower and upper uncertainty values away from col_val, respectively, should be provided. While select helper functions such as starts_with() and ends_with() can be used for column targeting, it's recommended that one or two column names be explicitly provided in a vector.

prefix, postfix

Optional strings to insert before and/or after both col_val and col_uncert. Use a length 2 string c("", "uncert_prefix") if you want to apply a prefix to only one or the other column specification.

sep

Separator text for uncertainties

scalar<character> // default: " +/- "

The separator text that contains the uncertainty mark for a single uncertainty value. The default value of " +/- " indicates that an appropriate plus/minus mark will be used depending on the output context. Should you want this special symbol to be taken literally, it can be supplied within the I() function.

...

One or more character vectors.

NULLs are removed; scalar inputs (vectors of length 1) are recycled to the common length of vector inputs.

Like most other R functions, missing values are "infectious": whenever a missing value is combined with another string the result will always be missing. Use dplyr::coalesce() or str_replace_na() to convert to the desired value.

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.