Last active
February 4, 2019 21:30
-
-
Save charliejhadley/7b0370a84b2c95f06ab6db285f536d90 to your computer and use it in GitHub Desktop.
bookdown kable formatting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
output: html_document | |
editor_options: | |
chunk_output_type: console | |
--- | |
```{r setup, include=FALSE, message = FALSE, warning = FALSE} | |
knitr::opts_chunk$set( | |
echo = FALSE, | |
message = FALSE, | |
warning = FALSE | |
) | |
``` | |
# kable options | |
```{r} | |
library("kableExtra") | |
library("tidyverse") | |
library("glue") | |
``` | |
with kableeextra | |
```{r} | |
tibble( | |
raw_markdown = c("The home of R", | |
"The home of R packages", | |
"Where R is downloaded from"), | |
R = c("The scripting language", | |
"The code that you write", | |
""), | |
RStudio = c("The application where you write R code", | |
"The application where R developers write R packages", | |
"The company that makes the RStudio application") | |
) %>% | |
kable() %>% | |
kable_styling("condensed") %>% | |
row_spec(1:3, background = "white") %>% | |
column_spec(2, background = "#f8f8f8", include_thead = TRUE) | |
``` | |
```{r} | |
col_CRAN <- c("The home of R", | |
"The home of R packages", | |
"Where R is downloaded from") | |
col_R <- c("The scripting language", | |
"The code that you write") | |
col_RStudio <- c("The application where you write R code", | |
"The application where R developers write R packages", | |
"The company that makes the RStudio application") | |
make_bullets <- function(column){ | |
glue("<ul><li>", paste0(column, collapse = "</li><li>"), "</li></ul>") | |
} | |
tibble( | |
html = make_bullets(col_CRAN), | |
R = make_bullets(col_R), | |
RStudio = make_bullets(col_RStudio) | |
) %>% | |
kable(escape = FALSE) | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment