This is an R HTML document. When you click the chunk like this:

Complex table designed in gt()
  library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ ggplot2   3.5.1     ✔ tibble    3.2.1
## ✔ lubridate 1.9.3     ✔ tidyr     1.3.1
## ✔ purrr     1.0.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
  library(gt)
  library(palmerpenguins)

  penguins %>%
    group_by (species) %>%
    summarize_at(
      .vars = c(
        "bill_length_mm",
        "bill_depth_mm",
        "flipper_length_mm",
        "body_mass_g"
        ),
      .funs = ~ mean(., na.rm = TRUE)
      ) %>%
    gt(rowname_col = "species") %>%
    tab_header(
              title = md("Summary of penguins dataset"),
              subtitle = md("Uses of the data")
              ) %>%
    cols_label(
              bill_length_mm = md("Bill Length,<br>mm"),
              bill_depth_mm = md("Bill depth,<br>mm"),
              flipper_length_mm = md("Flipper length,<br>mm"),
              body_mass_g = md("Body Mass,<br>kg")
              ) %>%
    opt_align_table_header(align = "left") %>%
    fmt_number(columns = everything()) %>%
    fmt_number(columns = body_mass_g, scale_by = 1/1000) %>%
    cols_width(bill_length_mm ~ px(100),
              bill_depth_mm ~ px(100),
              flipper_length_mm ~ px(100),
              body_mass_g ~ px(100),
              everything() ~ px(100))
Summary of penguins dataset
Uses of the data
Bill Length,
mm
Bill depth,
mm
Flipper length,
mm
Body Mass,
kg
Adelie 38.79 18.35 189.95 3.70
Chinstrap 48.83 18.42 195.82 3.73
Gentoo 47.50 14.98 217.19 5.08