I am trying to add an additional header row in a long kable. Below is an example of what my current table looks like:
Here is an example of what I am trying to achieve:
I have not been able to find any description of this. If anyone has any ideas how I might accomplish this it would be much appreciated.
Code for kable table:
library(kableExtra)
my_data <- mtcars[1:8, 1:6]
kable(my_data, booktabs = TRUE, align = "c", table.attr = "style='width:100%;'") %>%
kable_styling(bootstrap_options = c("striped"), position = "center", full_width = FALSE) %>%
group_rows("Set1", 1, 4) %>%
group_rows("Set2", 5, 8)
It's not very important that the final table looks exactly like the image, if the header row is another full row or something like that, that is totally fine. Thanks in advance.


I don't there's a "kable" way of doing it. Here I mimicked your output by adding the column names as a row in
my_data, then userow_specto decorate that row.