Hao Zhu | bacd2f3 | 2017-10-11 14:06:36 -0400 | [diff] [blame] | 1 | --- |
| 2 | title: "cell_formatter_pdf" |
| 3 | author: "Hao" |
| 4 | date: "10/11/2017" |
| 5 | output: pdf_document |
| 6 | --- |
| 7 | |
| 8 | ```{r, include=F} |
| 9 | library(knitr) |
| 10 | library(kableExtra) |
| 11 | library(dplyr) |
| 12 | ``` |
| 13 | |
| 14 | ```{r} |
Hao Zhu | 9ce317e | 2017-10-12 18:19:55 -0400 | [diff] [blame] | 15 | mtcars[1:25, 1:5] %>% |
Hao Zhu | bacd2f3 | 2017-10-11 14:06:36 -0400 | [diff] [blame] | 16 | mutate( |
| 17 | mpg = ifelse(mpg > 21, |
| 18 | cell_spec(mpg, "latex", color = "green", bold = T), |
| 19 | cell_spec(mpg, "latex", color = "red", italic = T)), |
Hao Zhu | 9ce317e | 2017-10-12 18:19:55 -0400 | [diff] [blame] | 20 | disp = cell_spec(disp, "latex", background = spec_color(disp), |
| 21 | color = "white", bold = T) |
Hao Zhu | bacd2f3 | 2017-10-11 14:06:36 -0400 | [diff] [blame] | 22 | ) %>% |
| 23 | kable("latex", escape = F, booktabs = T) %>% |
| 24 | row_spec(0, angle = 90) |
| 25 | ``` |