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)
)
Run the code above in your browser using DataLab