knitr::opts_chunk$set(echo = TRUE)

library(gt)

Create a display table based on iris Edgar Anderson's Iris Data.

gt(iris) %>%
  tab_spanner_delim(delim = ".") %>%
  cols_move_to_start(columns = Species) %>%
  fmt_number(
    columns = c(Sepal.Length, Sepal.Width, Petal.Length, Petal.Width),
    decimals = 1
  ) %>%
  tab_header(
    title = md("The **iris** dataset"),
    subtitle = md("[All about *Iris setosa*, *versicolor*, and *virginica*]")
  ) %>%
  tab_source_note(
    source_note = md("The data were collected by *Anderson* (1935).")
  ) %>%
  tab_options(latex.use_longtable = TRUE) %>% 
  tab_caption(md("The **iris** dataset"))


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