How to split kable over multiple columns?

Viewed 8055

I am trying to produce a "longitudinal" layout for long tables in RMarkdown with kable. For example, I would like a table to be split over two columns, like in the example below:

dd <- data.frame(state=state.abb, freq=1:50)
kable(list(state=dd[1:25,], state=dd[26:50,]))

However, this hack produces an output that looks a way worse than the normal kable output (for example the header is not in bold). Is there a "proper" way to do this using kable?

2 Answers

You can still use Kable with a slight modification to your code.

dd <- data.frame(state=state.abb, freq=1:50)

knitr::kable(
  list(dd[1:25,], dd[26:50,]),
  caption = 'Two tables placed side by side.',
  booktabs = TRUE
)

This code is a modification of this. You can also find more information about tables on that page

Related