The iframe tag and the WordPress iframe plugin are how to include HTML widgets in a WordPress blog post. The iframe tag is included in HTML5. Using iframes in a WordPress blog post is how you get the JavaScript associated with a widget to run in your post.

Here’s an example of how to create an HTML widget in R using an .R file. This could also be done in an .Rmd and knitted. Since I didn’t want to create an .html page from within RStudio using knitr, I just sourced the .R file:

library(htmlwidgets)
library(DT)
a <- datatable(iris)
saveWidget(a, "datatable-iris-example.html")

Next, import the .html file to your media library. Then, add the shortcode to your post. Here's how to encode it in the page when editing the blog post:

iframe seamless src="http://www.phillipburger.net/wordpress/wp-content/uploads/2015/05/datatable-iris-example.html" width="100%" height="500"

Note that I had to remove the open [ and closing ] brackets to avoid the code from being executed. When you add your shortcode to your post, add back the [ as the first character and the ] as the last character in the shortcode. This is how simple it is. Here's how it looks:

I am not aware of any other way to get R-created HTML widgets (JavaScript) to execute in a blog post. If you have any suggestions, please post a comment!

This post is a review of the Udemy.com course Building Web Apps in R with Shiny. The course content creator was Mason DeCamillis. Kudos straight up to Mason for not spending any time bootstrapping enrollees in R. Needing to know some R is mentioned in the course description. Overall, the course exceeded my expectations and I give it five stars.

Some aspects of the platform determine the quality of the course and I mention three in this review. The first is the video quality. I got several lectures in without being able to read the code on the screen. Turns out the option to improve the video quality is there from the first lecture and I just didn’t see it…if you take the course, immediately set quality to 720 and use fullscreen.

Video lectures work best when the lecturer uses their natural voice. For this course, the vocabulary is typical, spoken English, and is well enunciated. The tone is like a peer-to-peer conversation.

A key takeaway insight from the course is the concept of reactive programming that Shiny is an example of. Lecture 5 includes a diagram of the reactive programming model. In this model, the user makes a change to a control on the web page, the change is sent to the server, the server reprocesses the user interface, and the new page is sent to the user’s browser. For a field that takes an input value, the screen updates as soon as the new input is entered; the user doesn’t ever need to refresh the page. This is pretty cool and is all you really need to know about reactive programming to develop and deploy Shiny apps.

The course content on deploying a Shiny app to an AWS instance is killer! Having this included in the course is the difference between a four and five-star rating.

An annoying aspect of some other on-line courses is that links to the discussion boards and content are taken down after the course is over. For this platform, access to the course material is lifetime.

A convenience that I would like to see added to the course page is a link to one .zip file that contains all the code examples and data. The code examples, and any data needed to execute the examples, are available in a sidebar in the respective lecture where the code is introduced. This is logical, but if you leave and come back, you have to scroll through the videos to find the download link. After being away from the course for 21 days, it took me 10 minutes of clicking around to learn for the second time that the examples accompany the lecture they are introduced in.

Wrap

The course is engaging and the time investment is low. Is it worth the $119? My time is worth $55/hour and I estimate that I’ll end up saving eight to 10 hours as a result of the exposure to the material. So, I’d say yes, it’s worth it.

The course Building Web Apps in R with Shiny is practical, meets it’s aims, and is a good use of time and money. If you have been wanting to get going on building and deploying your own Shiny apps, take the course.