I got something similar working by
- moving the knitr::kable(head(mtcars)) inside a return() at the end of the function.
- including results = 'asis'
e.g.
---title: "Markdown example"output: html_document---```{r setup, include=FALSE}knitr::opts_chunk$set(echo = TRUE)```# Markdown example```{r results = 'asis'}make_outputs <- function(){print(plot(mtcars$mpg, mtcars$cyl))print(hist(mtcars$cyl))return(knitr::kable(head(mtcars)))}make_outputs()```
If you use ggplot for plots, you will need to wrap your plot inside print()