Hao Zhu | d4f5498 | 2020-10-07 16:26:35 -0400 | [diff] [blame] | 1 | --- |
| 2 | title: "In-table Plots" |
| 3 | output: |
| 4 | html_document: |
| 5 | theme: cosmo |
| 6 | --- |
| 7 | |
| 8 | ```{r, include=F} |
| 9 | knitr::opts_chunk$set(warning = F, message = F) |
| 10 | ``` |
| 11 | |
Hao Zhu | 75e2ad0 | 2020-10-21 22:09:53 -0400 | [diff] [blame] | 12 | Sometimes it's a delight to see plots in a table. Here we provide recipes for a few common tasks using both `kableExtra`'s built-in functions and external libraries, including `ggplot2`, `sparkline` and `plotly`. |
Hao Zhu | d4f5498 | 2020-10-07 16:26:35 -0400 | [diff] [blame] | 13 | |
Hao Zhu | 75e2ad0 | 2020-10-21 22:09:53 -0400 | [diff] [blame] | 14 | In terms of `kableExtra`'s built-in plotting functions, since version 1.2.1, `kableExtra` includes these functions for the most common plotting tasks. Since I don't want to introduce an entire `ggplot2` dependency to this package, all these plotting functions were developed using base-R `plot`. Here I need to acknowledge the significant contribution from Bill Evans (@r2evans on github and SO), who wrote the general `spec_plot` function and improved the coding structure of these `spec_***` plotting functions. |
Hao Zhu | d4f5498 | 2020-10-07 16:26:35 -0400 | [diff] [blame] | 15 | |
| 16 | ```{r} |
| 17 | library(kableExtra) |
| 18 | library(plotly) |
| 19 | library(sparkline) |
| 20 | library(tidyverse) |
| 21 | ``` |
| 22 | |
Hao Zhu | 75e2ad0 | 2020-10-21 22:09:53 -0400 | [diff] [blame] | 23 | ## Summary Stats Table |
| 24 | |
| 25 | ```{r} |
| 26 | |
| 27 | ``` |
| 28 | |
| 29 | ### kableExtra built-in |
| 30 | |
| 31 | ```{r} |
| 32 | |
| 33 | ``` |
| 34 | |
Hao Zhu | d4f5498 | 2020-10-07 16:26:35 -0400 | [diff] [blame] | 35 | |