Hi folks,
kableExtra::collapse_rows provides a nice way to create tables with collapsed (or merged) cells by row. I was wondering if kableExtra also provides a method to collapse cells by column. For instance, in the example below, I would like to merge the b's in the 2nd row of my table.
If this functionality is not available in kableExtra, are you aware of a package that provides the ability to:
- collapse cells by column and/or row, and
- add column headers on grouped columns
?
Thanks in adance
require(knitr)
require(kableExtra)
dt <- data.frame(
var1 = c(1, 2, 3, 3, 4),
var2 = c('a', 'b', 'c', 'c', 'e'),
var3 = c('f', 'b', 'g', 'h', 'i')
)
kable(dt, align = "c") %>%
kable_styling(full_width = FALSE) %>%
collapse_rows(columns = 1:3, valign = "middle")
```