4

How to include a shiny app in a bookdown document? There is an example for including the miniUI in the documentation, but not on how to include an own app.

I tried to include "myapp" in the subdirectory "myapp" either as an integrated file (app.R) or as the two files server.R and ui.R using include_app("myapp") or runApp("myapp"), but this doesn't work.

Cœur
  • 37,241
  • 25
  • 195
  • 267
arnyeinstein
  • 669
  • 1
  • 5
  • 14

1 Answers1

5

This question was asked a while back, but I will provide an answer in case anyone else is trying to set this up.

Both functions knitr::include_app() and knitr::include_url() require an URL, which should be the address to the website where you publish your Shiny app. So if you want to build your own app, I suggest you first publish it to the web, and then embed it into the HTML code produced by bookdown using the instructions found here: https://bookdown.org/yihui/bookdown/web-pages-and-shiny-apps.html. Basically, you will need to:

  1. Create a free account at shinyapps.io,
  2. Publish Shiny app (with or without the miniUI package package) following instructions here: https://docs.rstudio.com/shinyapps.io/index.html and
  3. Run the function knitr::include_app() to integrate your Shiny app into your bookdown, as decribed here https://bookdown.org/yihui/bookdown/web-pages-and-shiny-apps.html..

With a FREE account at shinyapps.io, you can publish up to 5 apps. I recommend you try the miniUI package to publish your Shiny app, because it will make the app easily fit into the HTML page generated by bookdown.

DR11
  • 51
  • 1
  • 2