Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to integrate shiny in bookdown

Tags:

r

shiny

bookdown

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.

like image 387
arnyeinstein Avatar asked Oct 19 '25 04:10

arnyeinstein


1 Answers

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.

like image 93
DR11 Avatar answered Oct 20 '25 20:10

DR11



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!