How to embed a Shiny app into your blog posts

Shiny
Shorts
This is a one-minute blog post to share how to incorporate Shiny apps in blog posts.
Author

Albert Rapp

Published

May 9, 2022

Today’s a short blog post. It’s mainly for sharing a cool trick I just learned.

Here’s a simple template to incorporate your Shiny app into an HTML file. For instance, you can incorporate your shiny app into your blog post like I do here. Simply exchange the src argument by your Shiny app’s URL and then you’re good to go. Here, I use the app that I have shown you a couple of months ago.

<iframe src="https://rappa.shinyapps.io/interactive-ggplot" data-external="1" width="925px" height="800px">
</iframe>

From what I could tell, this is same code that knitr::include_app() drops. But including the iframe manually let’s you adjust the width and height of your frame. Beware that you will have to choose the dimensions large enough for your Shiny app.

UPDATE: Originally, I had demonstrated the above code chunk here. But that causes unnecessary traffic on my shinyapps.io account, so I removed the demo.


Enjoyed this blog post?

Here are three other ways I can help you:

3 Minutes Wednesdays

Every week, I share bite-sized R tips & tricks. Reading time less than 3 minutes. Delivered straight to your inbox. You can sign up for free weekly tips online.

Data Cleaning With R Master Class

This in-depth video course teaches you everything you need to know about becoming better & more efficient at cleaning up messy data. This includes Excel & JSON files, text data and working with times & dates. If you want to get better at data cleaning, check out the course page.

Insightful Data Visualizations for "Uncreative" R Users

This video course teaches you how to leverage {ggplot2} to make charts that communicate effectively without being a design expert. Course information can be found on the course page.