Embedding a knitted Rmd report in a uiOutput


#1

I'm trying to embed a knitted Rmd report in a uiOutput window of a shiny app. For simplicity, the Rmd Document is:


title: "Rep Rpeort"
theme: yeti
date: "r format(Sys.time(), '%d %B, %Y')"
output: html_document

require(knitr)
knitr::opts_chunk$set(echo=FALSE)
#kable(params)
kable(mtcars[1:10,],caption = "Table Caption")

If I knit this in Rstudio I get the nicely formatted report:

But if in shiny I use the expression:

output$Report <- renderUI({
HTML(markdown::markdownToHTML(knit('Report2.Rmd', quiet = TRUE),fragment.only = TRUE))
})

what shows up in the UI window is:

Totally unformatted and useless. What am I missing? How can I get my uiOutput to display the same report as I get using knit in RStudio?

Thanks!


#2

One easy way is to knit it and get the html you wish. After that
in the server side :

output$my.document <- renderUI({
  includeHTML("myreport.html")
  })

and to the ui :

uiOutput("my.document")

The above solution is good for static reports.