How to embed Shiny

Since Blogdown is for static websites, it cannot run Shiny in rmarkdown directly. According to discussion here and document here.

The only way to do it is using iframe and write outside the chunk:
<iframe src="https://liuyanguu.shinyapps.io/bcl_app/" width=1000 height=800"></iframe>

There is also a built-in function in knitr to do the same thing and write in the chunk. The only difference is that we can only set height, and the shiny app would appear slightly different with the siderbarPanel at the top and the mainPanel beneath it.

knitr::include_app("https://liuyanguu.shinyapps.io/bcl_app/", height = "100%")
# by the way, you can also embed your slides in a similar way, for example:
knitr::include_url('https://timmastny.rbind.io/slides/first_presentation#2')

My Shiny app example

I modified based on the great example and tutorial by Dean Attali, whom I found is also the author of ggExtra’s marginal plot. It is definitely better than Shiny’s own training materials.
Thanks a lot. Yes, I donated.

If this embedment doesn’t appear well on your screen, here is the link to the app.

The code for the app
All the code is in one file. I did not split ui with server.
The code are hosted on github.