This is an R HTML document. When you click the chunk like this:
Complex table designed in gt()library(tidyverse)
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 |