knitr::opts_chunk$set(echo = TRUE)
library(gt)
library(tidyverse)
readr::read_csv(
  system.file("extdata", "sp500.csv", package = "gt"),
  col_types = "cddddd"
) %>%
  gt() %>%
  fmt_date(
    columns = Date,
    date_style = 6) %>%
  fmt_currency(
    columns = c(High, Open, Low, Close),
    currency = "USD",
    scale_by = 1/1000,
    pattern = "{x}K"
  ) %>%
  fmt_number(
    columns = c(Volume),
    decimals = 3,
    scale_by = 1E-9,
    pattern = "{x}B"
  )


rstudio/gt documentation built on Nov. 2, 2024, 5:53 p.m.