Hao Zhu | 9ce317e | 2017-10-12 18:19:55 -0400 | [diff] [blame] | 1 | --- |
| 2 | title: "cell_formatter_pdf" |
| 3 | author: "Hao" |
| 4 | date: "10/11/2017" |
| 5 | output: html_document |
| 6 | --- |
| 7 | |
| 8 | ```{r, include=F} |
| 9 | library(knitr) |
| 10 | library(kableExtra) |
| 11 | library(dplyr) |
| 12 | ``` |
| 13 | |
| 14 | ```{r} |
| 15 | mtcars[1:15, 1:5] %>% |
| 16 | mutate( |
| 17 | mpg = cell_spec(mpg, "html", color = "white", background = spec_color(mpg)), |
| 18 | disp = cell_spec(disp, "html", color = spec_color(disp, option = "B"), |
| 19 | bold = T, font_size = spec_font_size(disp)), |
| 20 | hp = cell_spec(hp, "html", hover_message = paste0("cyl:\n", cyl)) |
| 21 | ) %>% |
| 22 | kable("html", escape = F) %>% |
| 23 | kable_styling("condensed", full_width = F) |
| 24 | ``` |
Hao Zhu | 457acb4 | 2017-10-14 17:37:02 -0400 | [diff] [blame] | 25 | |
| 26 | ```{r} |
| 27 | iris[, 1:4] %>% |
| 28 | mutate_all(function(x){ |
| 29 | cell_spec(x, "html", |
| 30 | color = spec_color(x, option = "A"), |
| 31 | font_size = spec_font_size(x), |
| 32 | bold = T) |
| 33 | }) %>% |
| 34 | kable("html", escape = F, booktabs = T, linesep = "", align = "c")%>% |
| 35 | row_spec(0, angle = 270, align = "right") %>% |
| 36 | kable_styling(full_width = F) |
| 37 | ``` |