R in the web – with Shiny App

How do you host R application on the internet?  One of the available service is from shinyapps.io.  This is a hosting service that allows you to deploy your R application to the server, and shared them on your web pages.

It was really easy to setup.  I used RStudio to develop my shiny app, this example below is based on a sample application and with some modification.  Once the application is developed and tested in RStudio.  All I needed is to sign up for a free account in shinyapps.io, and deploy my application to the server.

R is an excellent programming platform to do data analysis.  It is open source and has an extensive list of other add-on packages that are will give you a quick jump start into the analytic world.  Below is an example using the Text Mining ™ and WordCloud package.  This app basically allows you to select the book you are interested, and it will do word count analysis on the book and display it in a WordCloud visualization.  You can also you to select the book, and adjust the “Min Frequency” and “Max # of Words” for the visualization.  Embedded below is a “live” interactive R application using an iFrame.  Please feel free to click, slide the controls, and play with it.

A shiny app basically contains a few simple files following some naming conventions.  A typical application will have:

  • global.R – this file contains all the common setup for your application
  • server.R – this file contains the server part of the code, meaning all the back-end data crunching works.
  • ui.R – this file contains all the front-end user interface components, including both input and output interaction with the user.

Here are the 3 source files for this sample application.  As you can see, there are only a few lines of code, which clearly show how powerful the R language is.

(hint: click to zoom on image)


It is very simple but I do notice a few limitation.  With the free account, you can only have public app, meaning everybody can see your application. If you do want to protect your content you will need to sign up for a paid subscription.  There also seems to be some limitation on the run time.  For this specific example, if we try to analyse other longer books, it will get a timeout and disconnect, so I assume that there is a limit on the execution.

If you are interested, the source code in this example is available in GitHub.