*** UPDATE: On 1/23/2015 Surprise! Microsoft announced the acquisition of Revolution Analytics. This is great news and as a result I will be adding that solution option into this mix along with Azure ML R Web Service. ***
In this multiple part series, I will share my journey reviewing and developing web applications with the analytics mega-star language R. Over the holidays I spent a good deal of time experimenting with open source R web applications and APIs. My ultimate goal was to feed R results to my Power BI Preview via the new Developer APIs or through other means. To achieve my goal, I needed to 1) find a suitable R web library, 2) ramp up on Azure Active Directory and OAuth 2.0 web app authentication, 3) learn the Power BI Developer REST API and 4) cook up the web code to combine these two cool solutions together.
Why would anyone want to integrate R into a web application or a dashboard? I can think of quite a few reasons. Top of mind when you add R to your solution, you open up a sea of analytical capabilities across statistics, forecasting, predictive modeling, machine learning, data visualization and other data crunching areas. Today R is often developed by a quant, scientist, statistician or analytics pro on a desktop using scripts. Static results might get emailed or embedded into a presentation limiting potential use and resulting business value. Web delivery allows for efficient distribution and exploration of R results by business subject matter experts. Simple interactive R insights shown alongside other relevant reports can improve decision context. For me personally, I have been obsessed with the power of R for a few years now. This specific topic touches on a few of my passions… analyzing data, creating dashboards, web development and creatively combining cool solutions.
Reviewing R Web Libraries and Frameworks
Delivering R in web apps is not a bleeding edge topic. There are a few options out in the wild and listed on the CRAN site FAQ – R Web Interfaces. When you review open source projects, keep in mind that you do need to take note of what projects are actively and continually supported. In my searches, I found two excellent options that were not even listed on the CRAN site: new Shiny by R Studio and the OpenCPU API that are actively supported and appear to be popular. *** Note Azure ML R Web Service will also be covered in this series. ***
Shiny for R
Shiny is a platform as a service (PaaS) for hosting R web applications. I have been following Shiny since the initial R Studio announcements. I am an R Studio fan and thought I’d spin up a quick Shinyapps.io trial account to see how the integration of their offering might work. Unlike R Studio, it looks like Shiny may not be truly free depending on your use case. Regardless, I did proceed with my evaluation.
After creating my trial Shinyapps.io account, I was able to easily download the Shiny developer libraries into my free R Studio desktop for authoring and publishing. The framework was straight-forward to use after I worked through their Getting Started material and a few of their tutorials. Development with Shiny is not non-technical user-friendly per se. Existing R developers could probably get the hang of it. The solution does offer rich HTML controls called Widgets. Although the web site claims you need no programming skills, most likely you will want to sling HTML and CSS code to beautify or integrate the Shiny R functionality into other apps like I want to do. They do have a gallery showcasing much better demos of their solution.
OpenCPU HTTP API for R
During my evaluations, I ended up really liking OpenCPU’s R web framework. OpenCPU is an open source solution for embedded R computing. The software can be freely used, modified and redistributed for both for open source and proprietary projects in academia, industry or elsewhere. All parts of OpenCPU are released under the Apache2 license. The free OpenCPU framework provides a reliable and interoperable HTTP API for R data analysis. You can either call the public servers or download and install OpenCPU’s code on your own servers.
For my evaluation, I launched my favorite HTML editor and added the OpenCPU include files to my test HTML pages. In two hours, I was able to figure out how to generate a JSON that I could ultimately feed into the Power BI REST API. Although I didn’t spend any time beautifying my test page user interface, you can take a peek at my results and code by viewing the HTML page source in your web browser. I could have placed the OpenCPU tests in an HTML iframe just like I did for the Shiny example. I chose not to do that here so your HTML code view would be much easier to read.
Test 1 – Executing R code snippets to compute result (VIEW LIVE DEMO)
Test 2 – Plotting a data set with R (VIEW LIVE DEMO)
Test 3 – R result to JSON for use within Power BI (VIEW LIVE DEMO)
Combining OpenCPU R results with Power BI
Now that I have found a free and easy way to call R on the web to generate output. I will continue on my journey of 2) ramping up on Azure Active Directory and OAuth 2.0 web app authentication, 3) learning the Power BI Developer REST API and 4) cooking up the web code to combine these two cool solutions together. In my next article in this series, I will walk through the integration steps to get R results fed into the Power BI REST API and finally wrap up this series with displaying the OpenCPU R results on a Power BI dashboard tile. In the meantime, enjoy playing with these two cool R web application frameworks.