Rawpixel 722814 unsplash

Embed R functionality in your website or application

About a year ago, we rolled out a major overhaul to Secure Data Kit’s reporting system. You can read the link for all the cool stuff we did but it included things like making data exportable, integrations with Tableau and Power BI, and providing a place where our clients could upload their own R scripts. If you’re not familiar with R, it’s a robust and vibrant statistical programming language popular in the healthcare community. It’s easy to spin up really awesome data visualizations, it’s open source, and it’s fast!

To make the R implementation as scalable as possible, we put it on its own server and wrapped it in an API. This allowed Secure Data Kit to execute R scripts without affecting core SDK performance.

Then it hit us — if we find value executing R via API, maybe others would too? After all, it’s popular and powerful but the most common way to run R scripts is on your desktop via something called R Studio. What if you wanted to embed it in your website? Or share results? ShinyApps provided about 50% of that functionality but lacked having total control over the environment. So we created Embedded R, an R API that allows others to use our infrastructure to execute an R script and pass the data back. Sometimes that data is simple — maybe a table or a CSV. Other times it’s complex like a PDF or word document.

One of our clients, a Very Large Healthcare Organization, just rolled out an implementation using the embedded R API. This is the perfect use case for it because they had some specific requirements:


  1. They wanted total control over the User Experience and they wanted it to be web based to make it accessible and centralized anywhere

  2. Ministries of health or implementing partners use Secure Data Kit (or some other data collection platform) to collect data about a particular disease -- this might be geographic or disease data (or both!)

  3. They wanted to cross reference that data against data in a MySQL database

  4. Lastly, they wanted to execute an R script that would analyze these joined datasets and return a really cool word doc w/ the results



Since we have total control over the environment we can do a lot of cool things with the resulting report. We can automatically run it every week, we can share the results via email to a subset of users, or we can embed it into a website.

Making our own software that we use internally available to clients has been super helpful to us. Interested in learning more? Reach out to us!
Get Friendly Support