How to embed a Shiny app in blogdown?

Antoine Soetewey 2020-01-07 2 minute read

Step-by-step guide

If you have developed and deployed a Shiny app and would like to embed it in blogdown, follow these steps:

  1. create a new post as usual
  2. add output: html_document if it is not already included in the YAML metadata
  3. insert the following HTML code in the body of the post:
<iframe height="800" width="100%" frameborder="no" src="https://antoinesoetewey.shinyapps.io/statistics-201/"> </iframe>

You should change the URL with the URL of your deployed Shiny app (after src=, do not forget that the URL should start with http:// or https:// and should be surrounded by "). Moreover, you can modify the height, the width and include or not a frame border with the corresponding tags.

Here is an example of the result with one of my Shiny app (link to the app):


Note that the app may not work if it has hit the monthly usage limit. Try again later if that is the case.

Code

Here is the entire .Rmd code in case you would like to use it for your own website:

If you encounter an issue, try loading the following packages in the body of your new post: shiny, widgetframe (you can load a package with the command library(widgetframe)). If one of the package is not installed yet, you can do it with the command install.packages("widgetframe").

Conclusion

Thanks for reading.

I hope this article helped you to embed a Shiny app in your blogdown website.

As always, if you have a question or a suggestion related to the topic covered in this article, please add it as a comment so other readers can benefit from the discussion.



Liked this post?

  • Get updates every time a new article is published (no spam and unsubscribe anytime):

  • Support the blog
  • Share on: