Test table 1

library(knitr)
library(kableExtra)
options(knitr.table.format = "html")
dt <- mtcars[1:5, 1:4]

kable(dt, booktabs = T, caption = "Demo Table") %>%
  kable_styling(bootstrap_options = c("striped", "condensed"), 
                latex_options = c("striped", "hold_position"),
                full_width = F) %>%
  add_header_above(c(" ", "Group 1" = 2, "Group 2[note]" = 2), strikeout = T,
                   italic = c(T, T, F), color = c("red", "yellow", "blue"), background = "gray", angle = 90, extra_css = "border: 2px solid;") %>%
  add_footnote(c("table footnote"))

Test table 2

kable(dt, format = "html") %>%
  kable_styling(full_width = F, 
                bootstrap_options = c("striped", "bordered")) %>%
  add_header_above(c(" ", "a" = 2, "b" = 2), line_sep = c(10, 0, 10)) %>%
  add_header_above(c(" ", "c" = 3, "d" = 1)) %>%
  column_spec(1, "1in")


haozhu233/kableExtra documentation built on April 13, 2024, 6:49 p.m.