HTML can be directly included into both slidy and ioslides RMarkdown presentations, allowing for external content to be displayed through iframes. This allows you to embed Shiny dashboards hosted on the shinyapps.io platform into your RMarkdown presentations hosted on RPubs, and is a more cost effective manner of including Shiny apps into your RMarkdown presentations as active hours are only consumed while those slides with Shiny app containing iframes are displayed. Learn how to embed shinyapps.io hosted Shiny apps into your RPubs presentations in this online video.
- [Voiceover] If you have a shiny dashboard that you want to include in your R Markdown presentation, but you don't want your shinyapp.io active hours to be consumed the whole time that your presentation is displayed, you need to include your shiny dashboard with iframes. Let's see how to do that in RStudio. We'll go to RStudio to project in the top right hand corner. We'll open our project. We'll go to our exercise files, and we'll select 06_05 and select our project file.
You'll see that what opens is an R Markdown presentation. It's a slidy presentation, which again is my favorite, we can see that on line three. On line four we're using my personal css style sheet. And our presentation is called iframe Included Dashboard. If we scroll down the file to line 16, we can see that we're including an iframe, and this iframe is a previously deployed shinyapp. Let's have a look at how this looks. So we'll copy and paste that URL.
And we'll go to a web browser. And here we have our beautiful, responsively designed shinyapp. So here I have a high chart built in, a couple of other high charts as well. And what I want to do, is I want to see how this looks inside of my R Markdown presentation file. Now let's go back to RStudio. Scroll to the top of my file, just so we can see again what we're going to get. We're going to get a slidy presentation and if we press knit HTML, maximize our screen, we can see my presentation and if I go to the next slide with the right arrow key.
We can see that I don't have my iframe included. The reason for this, is the built in web viewer inside of RStudio isn't very good. It's not a proper web browser. But I do have one installed, so let's click open in browser. And this will display for me my HTML R Markdown presentation in the browser. Now I can press the C key to bring up the table of contents and go to the next slide, Shiny Dashboard, and here we can see, my embedded responsively designed shinyapp.
Now that I've embedded it, I can easily publish it to the RPubs platform by clicking publish in the top right hand corner. I select publish. I choose a title for this, so I will call this iframe embedded shinyapp. I'm not going to give it a description, and the slug I'll choose iframe embedded shinyapp. I'll click continue.
And once the presentation finishes loading we can see here my R Markdown HTML file deployed to RPubs and bring up the table of contents with the C key. We'll go to the next slide with the right arrow key, and we can see here my embedded responsively designed shiny dashboard. Which I can interact with just as if I navigated directly to the shinyapp itself. And my shinyapps.io active hours are only being consumed while this is being displayed on screen.
This is an exciting course for analysts who want to increase the relevance and visibility of their work. Make sure to watch the knowledge checks at the end of each chapter to test your new skills.
- Installing and configuring RStudio
- Using R Markdown
- Adding slides to templates
- Working with code and charts
- Publishing presentations with RPubs
- Developing interactive charts and visualizations with Shiny
- Deploying presentations with shinyapps.io
- Making Shiny dashboards