blob: a725b76453b15e2ce724c93f9403e6c81e31218f [file] [log] [blame]
Hao Zhu68449202018-10-16 16:01:19 -04001---
2title: "Using kableExtra in Radix"
3description: |
4 A new article describing how to use kableExtra in Radix
5author:
6 - name: Hao Zhu
7 url: https://github.com/haozhu233
8date: "`r Sys.Date()`"
9output: radix::radix_article
10---
11
Hao Zhu72917f92019-03-15 18:41:42 -040012**Starting from kableExtra 1.1.0, you don't need to turn on this option as it's turned on by default for Radix and gitbook, for everyone's convenience. This Documentation is here to help you understand the logics behind the scene. **
13
14**If you want to this kind of native support to other html format, please submit a PR and add the template name to [this line](https://github.com/haozhu233/kableExtra/blob/f3b6aa4bf1648979bbf48bb6f827755387eebed5/R/zzz.R#L23).**
15
Hao Zhu68449202018-10-16 16:01:19 -040016People 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)`.
17
Hao Zhu72917f92019-03-15 18:41:42 -040018
Hao Zhu68449202018-10-16 16:01:19 -040019```{r, echo = T}
20library(kableExtra)
Hao Zhu72917f92019-03-15 18:41:42 -040021# options(kableExtra.html.bsTable = T) # No need for version 1.1.0+
Hao Zhu68449202018-10-16 16:01:19 -040022
23kable(iris[1:6, ], caption = "kable with kableExtra") %>%
24 kable_styling(c("striped", "hover", "condensed"), full_width = F,
25 position = "left") %>%
26 add_header_above(c("numerical" = 4, "categorical" = 1)) %>%
27 column_spec(1, bold = T) %>%
28 row_spec(0, italic = T)
29```
30
31
32Comparing with other table options
33
34```{r, echo = T}
35kable(iris[1:6, ], caption = "Basic kable")
36```
37
38```{r, echo = T}
39rmarkdown::paged_table(iris)
Hao Zhu6e631882018-10-16 16:33:10 -040040```
41
42# Appendix
43Here 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
44
Hao Zhu72917f92019-03-15 18:41:42 -040045![](radix_no_bs.png)