How do you run a Shiny runtime RMarkdown file via Plumber?

Viewed 98

I have an R app running that uses Plumber to serve some RMarkdown files via plumber::include_rmd. I'd like to serve a markdown file that uses the Shiny runtime, but I get a pandoc error when attempting to hit the route that serves the shiny rmarkdown file.

The markdown file is valid, and can be served using rmarkdown::run("./path/to/file.Rmd") successfully.

It appears the path to the static resources needed to build the pages are unable to be found.

My route looks like this:

#' @get /shiny
#' @serializer html
function(res) {
  # rmarkdown::render("../markdown/shiny.Rmd") # This doesn't work either!
  include_rmd("../markdown/shiny.Rmd", res)
}

And the RMarkdown file looks like this:

---
title: "Shiny Document"
output: html_document
runtime: shiny
---


    ```{r, echo=FALSE}
    numericInput("rows", "How many cars?", 5)

    renderTable({
      head(cars, input$rows)
    })
    ```

    ```{r, echo=FALSE}
    sliderInput("bins", "Number of bins:", 30, min = 1, max = 50)

    renderPlot({
      x <- faithful[, 2] # Old Faithful Geyser data
      bins <- seq(min(x), max(x), length.out = input$bins + 1)

      # draw the histogram with the specified number of bins
      hist(x, breaks = bins, col = "darkgray", border = "white")
    })
    ```

I get the following error:

/usr/local/bin/pandoc +RTS -K512m -RTS shiny.knit.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output shiny.html --lua-filter /Library/Frameworks/R.framework/Versions/4.1/Resources/library/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /Library/Frameworks/R.framework/Versions/4.1/Resources/library/rmarkdown/rmarkdown/lua/latex-div.lua --self-contained --variable bs3=TRUE --standalone --section-divs --template /Library/Frameworks/R.framework/Versions/4.1/Resources/library/rmarkdown/rmd/h/default.html --no-highlight --variable highlightjs=1 --id-prefix section- --variable theme=bootstrap --mathjax --variable 'mathjax-url=https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' --include-in-header /var/folders/1s/93d9gz4n1172t5syd1nq289r754dn5/T//RtmpPASBr0/rmarkdown-str17f04e09a49c.htmlFile shared/ionrangeslider/js/ion.rangeSlider.min.js not found in resource pathError: pandoc document conversion failed with error 99

I am able to find the rangeslider JS by manually inspecting the rmarkdown package.

0 Answers
Related