library(magrittr) library(gt) library(ggplot2) library(htmltools) library(gtExtras) #data = read.csv('https://docs.google.com/spreadsheets/d/1Bx5aKWk5ltA9HqU4Ma2dtdr12ih7ev5ZFyAeiFgqXw8/export?exportFormat=csv') data = read.csv('pop.csv') head(data) table <- gt(data) %>% tab_row_group( rows = which(rownames(data) %in% rownames(data[data$D1 == "C11" ],)), label = "C11" ) %>% tab_row_group( rows = which(rownames(data) %in% rownames(data[data$D1 == "C12" ],)), label = "C12" ) %>% #tab_options(table.width = "100%") %>% # row_group_order(groups=c("Copper","Plastic")) %>% tab_header(title = gt::html("