9

I want to use function knitr::kable() in an RStudio notebook. If column names are short, the spaces between columns are small and it makes information hard to understand (see figure below). It seems that padding does not work in this situation. Is there a way to make spaces between the columns (indicated by yellow arrows) larger in RStudio notebooks?

library(magrittr)
iris %>% 
  setNames(c("A", "B", "C", "D", "E")) %>%
  head() %>%
  knitr::kable(padding = 20)

GegznaV
  • 4,938
  • 4
  • 23
  • 43

1 Answers1

9

You could use kableExtra for nicer styling in general, including wider column spacing by default.

library(magrittr)
library(kableExtra)

iris %>% 
  setNames(c("A", "B", "C", "D", "E")) %>%
  head() %>%
  knitr::kable() %>% 
  kable_styling()
joshpk
  • 729
  • 4
  • 11