A new article describing how to use kableExtra in Radix
People may find some features in kableExtra
, such as hovering/striped rows are not working in radix
. The reason is that kableExtra
relies on bootstrap
stylesheet to do these jobs while radix
doesn’t have those css load. Therefore you need to tell kableExtra
to load the table css for you by setting options(kableExtra.html.bsTable = T)
.
library(kableExtra)
options(kableExtra.html.bsTable = T)
kable(iris[1:6, ], caption = "kable with kableExtra") %>%
kable_styling(c("striped", "hover", "condensed"), full_width = F,
position = "left") %>%
add_header_above(c("numerical" = 4, "categorical" = 1)) %>%
column_spec(1, bold = T) %>%
row_spec(0, italic = T)
Sepal.Length | Sepal.Width | Petal.Length | Petal.Width | Species |
---|---|---|---|---|
5.1 | 3.5 | 1.4 | 0.2 | setosa |
4.9 | 3.0 | 1.4 | 0.2 | setosa |
4.7 | 3.2 | 1.3 | 0.2 | setosa |
4.6 | 3.1 | 1.5 | 0.2 | setosa |
5.0 | 3.6 | 1.4 | 0.2 | setosa |
5.4 | 3.9 | 1.7 | 0.4 | setosa |
Comparing with other table options
kable(iris[1:6, ], caption = "Basic kable")
Sepal.Length | Sepal.Width | Petal.Length | Petal.Width | Species |
---|---|---|---|---|
5.1 | 3.5 | 1.4 | 0.2 | setosa |
4.9 | 3.0 | 1.4 | 0.2 | setosa |
4.7 | 3.2 | 1.3 | 0.2 | setosa |
4.6 | 3.1 | 1.5 | 0.2 | setosa |
5.0 | 3.6 | 1.4 | 0.2 | setosa |
5.4 | 3.9 | 1.7 | 0.4 | setosa |
rmarkdown::paged_table(iris)
Here is a screenshot of how table looks like if you don’t turn on the kableExtra.html.bsTable
option (with the same code). In fact, the only part that breaks is the striped
and hover
option. :P