Hao Zhu | c1f3841 | 2017-02-23 12:13:48 -0500 | [diff] [blame] | 1 | --- |
| 2 | title: "kable_styling - HTML" |
| 3 | output: html_document |
| 4 | vignette: > |
| 5 | %\VignetteIndexEntry{htmlTable Styling Guide} |
| 6 | %\VignetteEngine{knitr::rmarkdown} |
| 7 | %\VignetteEncoding{UTF-8} |
| 8 | --- |
| 9 | |
| 10 | # Plain HTML |
| 11 | ```{r} |
| 12 | library(knitr) |
| 13 | library(kableExtra) |
| 14 | dt <- mtcars[1:5, 1:2] |
| 15 | |
| 16 | kable(dt, format = "html") |
| 17 | ``` |
| 18 | |
| 19 | # Basic Bootstrap Table |
| 20 | ```{r} |
| 21 | kable(dt, format = "html") %>% |
| 22 | kable_styling() |
| 23 | ``` |
| 24 | |
| 25 | # Boostrap Table Options |
| 26 | ## Striped |
| 27 | ```{r} |
| 28 | kable(dt, format = "html") %>% |
| 29 | kable_styling(bootstrap_options = "striped") |
| 30 | ``` |
| 31 | |
| 32 | ## Striped + Hover |
| 33 | ```{r} |
| 34 | kable(dt, format = "html") %>% |
| 35 | kable_styling(c("striped", "hover")) |
| 36 | ``` |
| 37 | |
| 38 | ## Other bootstrap options |
| 39 | ```{r} |
| 40 | kable(dt, format = "html") %>% |
| 41 | kable_styling(c("striped", "bordered", "hover", "condensed", "responsive")) |
| 42 | ``` |
| 43 | |
| 44 | # "Thin" Table and Floating options |
| 45 | ```{r} |
| 46 | kable(dt, format = "html") %>% |
| 47 | kable_styling(c("striped", "bordered", "condensed"), full_width = F) |
| 48 | ``` |
| 49 | |
| 50 | ```{r} |
| 51 | kable(dt, format = "html") %>% |
| 52 | kable_styling(c("striped", "bordered", "condensed"), full_width = F, |
| 53 | float = "left", font_size = 10) %>% |
| 54 | add_header_above(c(" ", "Names" = 2)) %>% |
| 55 | add_header_above(c(" " = 2, "Names")) %>% |
| 56 | add_header_above(c("Names[note]" = 3)) %>% |
| 57 | add_footnote("note") |
| 58 | ``` |
| 59 | |
| 60 | |
| 61 | |