Hao Zhu | e10cfd3 | 2017-02-21 16:41:14 -0500 | [diff] [blame^] | 1 | --- |
| 2 | title: add_footnote - HTML |
| 3 | output: html_document |
| 4 | --- |
| 5 | |
| 6 | # Through Pandoc |
| 7 | ```{r through_pandoc} |
| 8 | library(knitr) |
| 9 | library(kableExtra) |
| 10 | dt <- mtcars[1:5, 1:2] |
| 11 | colnames(dt)[1] <- c("mpg[note]") |
| 12 | rownames(dt)[2] <- c("Mazda RX4 Wag[note]") |
| 13 | dt[3, 2] <- paste0(dt[3, 2], "[note]") |
| 14 | |
| 15 | kable(dt) %>% |
| 16 | add_footnote(c("footnote 1", "footnote 2", "footnote 3")) |
| 17 | ``` |
| 18 | |
| 19 | # Through HTML |
| 20 | ## Plain HTML |
| 21 | ```{r through_html} |
| 22 | kable(dt, format = "html") %>% |
| 23 | add_footnote(c("footnote 1", "footnote 2", "footnote 3")) |
| 24 | ``` |
| 25 | |
| 26 | ## HTML + bootstrap table |
| 27 | ```{r through_html_bootstrap} |
| 28 | kable(dt, format = "html", table.attr = htmlTable_styling()) %>% |
| 29 | add_footnote(c("footnote 1", "footnote 2", "footnote 3")) |
| 30 | ``` |
| 31 | |
| 32 | ## HTML + bootstrap narrow table |
| 33 | ```{r through_latex_longtable} |
| 34 | kable(dt, format = "html", |
| 35 | table.attr = htmlTable_styling(c("striped", "bordered"), |
| 36 | full_width = F)) %>% |
| 37 | add_footnote(c("footnote 1", "footnote 2", "footnote 3")) |
| 38 | ``` |