Skip to content

Instantly share code, notes, and snippets.

@haozhu233
Created October 28, 2020 06:22
Show Gist options
  • Save haozhu233/9c85d614439920fd9952a473aa21be35 to your computer and use it in GitHub Desktop.
Save haozhu233/9c85d614439920fd9952a473aa21be35 to your computer and use it in GitHub Desktop.
Test code in table.
---
title: "Untitled"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(message = FALSE)
```
## R Markdown
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
```{r cars}
my_code <- "x = 1
y = 2"
my_code2 <- "a = 1
b = 2"
eval(parse(text = my_code))
eval(parse(text = my_code2))
```
```{r}
library(kableExtra)
library(dplyr)
data.frame(
code1 = my_code,
code2 = my_code2
) %>%
mutate_all(~paste0('<code>', gsub('\n', '<br>', .) , '</code>')) %>%
kbl(escape = F) %>%
kable_paper(full_width = F)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment