RMarkdown in Shiny Application
As per @elevendollar's request, this is what I ended up using:
library(shiny)
library(knitr)
rmdfiles <- c("file1.Rmd", "file2.Rmd")
mdfiles <- gsub("Rmd$", "md", rmdfiles)
a <- lapply(rmdfiles, knit, quiet = T)
ui <- shinyUI(
fluidPage(
withMathJax(
# loop over the files and create one tabPanel for each file
do.call(tabsetPanel,
lapply(mdfiles, function(f) tabPanel(f, includeMarkdown(f))))
)
)
)
server <- function(input, output) { }
shinyApp(ui, server)
I think knitting it and rendering a UI should work.
library(shiny)
library(knitr)
ui <- shinyUI(
fluidPage(
uiOutput('markdown')
)
)
server <- function(input, output) {
output$markdown <- renderUI({
HTML(markdown::markdownToHTML(knit('RMarkdownFile.rmd', quiet = TRUE)))
})
}
shinyApp(ui, server)