Quantcast
Viewing latest article 4
Browse Latest Browse All 5

Answer by BradlesP for why does kable not print when used within a function in rmarkdown

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()


Viewing latest article 4
Browse Latest Browse All 5

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>