Hao Zhu | 6844920 | 2018-10-16 16:01:19 -0400 | [diff] [blame] | 1 | --- |
| 2 | title: "Using kableExtra in Radix" |
| 3 | description: | |
| 4 | A new article describing how to use kableExtra in Radix |
| 5 | author: |
| 6 | - name: Hao Zhu |
| 7 | url: https://github.com/haozhu233 |
| 8 | date: "`r Sys.Date()`" |
| 9 | output: radix::radix_article |
| 10 | --- |
| 11 | |
| 12 | 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)`. |
| 13 | |
| 14 | ```{r, echo = T} |
| 15 | library(kableExtra) |
| 16 | options(kableExtra.html.bsTable = T) |
| 17 | |
| 18 | kable(iris[1:6, ], caption = "kable with kableExtra") %>% |
| 19 | kable_styling(c("striped", "hover", "condensed"), full_width = F, |
| 20 | position = "left") %>% |
| 21 | add_header_above(c("numerical" = 4, "categorical" = 1)) %>% |
| 22 | column_spec(1, bold = T) %>% |
| 23 | row_spec(0, italic = T) |
| 24 | ``` |
| 25 | |
| 26 | |
| 27 | Comparing with other table options |
| 28 | |
| 29 | ```{r, echo = T} |
| 30 | kable(iris[1:6, ], caption = "Basic kable") |
| 31 | ``` |
| 32 | |
| 33 | ```{r, echo = T} |
| 34 | rmarkdown::paged_table(iris) |
Hao Zhu | 6e63188 | 2018-10-16 16:33:10 -0400 | [diff] [blame^] | 35 | ``` |
| 36 | |
| 37 | # Appendix |
| 38 | 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 |
| 39 | |
| 40 | ![](radix_no_bs.png) |