The cols_merge_uncert() function

Let’s use the exibble dataset to create a simple, two-column gt table (keeping only the num and currency columns). We’ll format the num column with the fmt_number() function. Next we merge the currency and num columns into the currency column; this will contain a base value and an uncertainty and it’s all done using the cols_merge_uncert() function. After the merging process, the column label for the currency column is updated with cols_label() to better describe the content.

exibble |>
  dplyr::select(num, currency) |>
  dplyr::slice(1:7) |>
  gt() |>
  fmt_number(
    columns = num,
    decimals = 3,
    use_seps = FALSE
  ) |>
  cols_merge_uncert(
    col_val = currency,
    col_uncert = num
  ) |>
  cols_label(currency = "value + uncert.")
value + uncert.
49.950 ± 0.111
17.950 ± 2.222
1.390 ± 33.330
65100.000 ± 444.400
1325.810 ± 5550.000
13.255
NA