pad_fn | R Documentation |
This helper function adds whitespace to numeric values so that they can
be aligned on the decimal without requiring additional trailing zeroes.
This function is intended to use within the gt::fmt()
function.
pad_fn(x, nsmall = 2, pad0)
x |
A vector of numbers to pad/align at the decimal point |
nsmall |
The max number of decimal places to round at/display |
pad0 |
A logical, indicating whether to pad the values with trailing zeros. |
Returns a vector of equal length to the input vector
2-3
Other Utilities:
add_text_img()
,
fa_icon_repeat()
,
fmt_pad_num()
,
fmt_pct_extra()
,
fmt_symbol_first()
,
generate_df()
,
gt_add_divider()
,
gt_badge()
,
gt_double_table()
,
gt_duplicate_column()
,
gt_fa_column()
,
gt_fa_rank_change()
,
gt_fa_rating()
,
gt_fa_repeats()
,
gt_highlight_cols()
,
gt_highlight_rows()
,
gt_img_border()
,
gt_img_circle()
,
gt_img_multi_rows()
,
gt_img_rows()
,
gt_index()
,
gt_merge_stack_color()
,
gt_merge_stack()
,
gt_two_column_layout()
,
gtsave_extra()
,
img_header()
,
tab_style_by_grp()
library(gt)
padded_tab <- data.frame(x = c(1.2345, 12.345, 123.45, 1234.5, 12345)) %>%
gt() %>%
fmt(fns = function(x) {
pad_fn(x, nsmall = 4)
}) %>%
tab_style(
# MUST USE A MONO-SPACED FONT
# https://fonts.google.com/?category=Monospace
style = cell_text(font = google_font("Fira Mono")),
locations = cells_body(columns = x)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.