2
votes

I am using R Markdown and I would like to render a table without row color banding in my R bookdown::gitbook document. With kableExtra::column_spec I can specify all the columns should be white like this:

`Table 2.1` <- data.frame(
  Algorithm  = c("Linear discriminant analysis", "Generalized Linear model"),
  Package = c("`MASS`", "`stats`"), 
  Code = c("`predict(obj)`", "`predict(obj, type = 'response')`"))

library(kableExtra)
kable(`Table 2.1`) %>% column_spec(1:3, background = "white")

but listing every column number is very kludgy.

What is the right way to specify that a kable table should not use row color banding?

1

1 Answers

3
votes

Simply using kable_styling() without arguments gives rows with color bands.

library(kableExtra)
mtcars %>% dplyr::select(mpg,hp) %>% 
  kable() %>% kable_styling()