I am trying to use kable
and kableextra
to create a table that has different grouped headers but the same column names in the sub-headers
For example, if you look at the section "Grouped Columns/Headers" (page 14) of Create Awesome LaTeX Table with knitr::kable andkableExtra it is grouped but the sub-header names are different:
library(knitr)
library(kableExtra)
dt <- mtcars[1:5, 1:6]
kable(dt, "latex", booktabs = T) %>%
kable_styling() %>%
add_header_above(c(" " = 1, "Group 1" = 2, "Group 2" = 2, "Group 3" = 2))
What I am trying to do is something like this with the cars as groups (only using two cars for example):
Mazda RX4 | Datsun 710
----------------------
mpg | cyl | mpg | cyl
----------------------
21.0| 6 | 21.4| 6
or as another example:
Group 1 | Group 2
------------------
x | y | x | y
------------------
a | 1 | b | 2
c | 3 | d | 4
Is this possible?
knitr::kable
, but you might trygt
. – Strapper