I have to repeat certain outputs in many rmarkdown reports and want to write a function that will be used for this.
The function call displays the graphs normally when I insert the rmd file, but not the enslaving data frames.
for instance
---
title: "Markdown example"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r mtcars}
make_outputs <- function(){
knitr::kable(head(mtcars))
plot(mtcars$mpg, mtcars$cyl)
hist(mtcars$cyl)
}
make_outputs()
```
Displays graphs, but not a kable table.
source
share