Web Frameworks for R – A Brief Overview

[This article was first published on R – Blog – Mazama Science , and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Having recently announced the beakr web framework for R, we have received several questions about context and why we choose beakr over other options for some of our web services. This post will attempt to answer some of those questions by providing a few opinions on beakr and other web frameworks for R.

The comparison will by no means be exhaustive but will attempt to briefly summarize some of the key distinctions each web framework has to offer. While there are some differences in the approach each package takes to developing web services, they all share similar basic functionality. In the end, the choice of a particular framework will come down largely to personal preference.

beakr

beakr is a small package and minimal web framework for quickly developing simple and stable web-services.

Features
  • Simple & Stable to get up and running
  • Programmatic tidy syntax

beakr (CRAN, GitHub) is a web framework for developing and deploying web services with R. beakr is inspired by the minimalist and massively-expandable frameworks offered by Express.js and Flask and is a reincarnation of the discontinued jug package by Bart Smeets. It allows users to assign specific blocks of R code to individual URL routes accessed by different HTTP protocols (POST, GET, PUT, etc.) using a familiar tidy syntax with a few key features we know we can rely on at Mazama Science. We use beakr because it offers a simple and no-fuss back-end that we know and can rely on.

View beakr “Hello, World!” example

plumber

plumber is a package that allows you to create a web API by decorating your existing R code with special decorator comments.

Features
  • Only requires a decorative comment to expose endpoints
  • Large community
  • Supported by RStudio

plumber (CRAN, GitHub) is an RStudio maintained package which gives it a tremendous amount of resources and support.

The plumber package is targeted at those who have an R code with a well-defined API who wants to make that API available as a web service. This makes plumber an excellent package for exposing R code that already exists. Not to mention the package is supported and maintained by RStudio — so you can be confident of its wide adoption and documentation.

However, we created beakr so that we can define REST services first and then write whatever code we want to handle each REST URL. This allows us to add all sorts of logging, caching, error handling, and other code required in our operational systems.

View plumber “Hello, World!” example

ambiorix

Ambiorix is an unopinionated web framework package for R and is designed to be flexible and extendable.

Features
  • Extensions! (Generators template extensions, CLI support)
  • Websocket support

The ambiorix(GitHub) is a new web framework package that we are excited to see! Though currently in development, John Coene (the creator) has already added some neat extensions such as a command-line interface and web template generators.

ambiorix and beakr offer similar approaches to developing web services and both draw inspiration from the ever popular express.js framework. ambiorix offers many functional features and is certainly a package to keep an eye on while it matures for an official release!

View ambiorix “Hello, World! example

fiery

Fiery is a flexible and lightweight framework for building web servers in R with explicit control.

Features
  • Complete control of server life-cycle events
  • Modular design

Fiery(CRAN, GitHub) is designed to have explicit control of server life-cycle events and flexibly handle them. It’s a framework that defines itself as lightweight with modularity and control in its design. We think fiery is best for developers that demand complete control of how their web-services work to handle requests, responses, and everything in between. fiery is no-doubt one of the most control-oriented frameworks that exist for R and as such, has some technical overhead. With that being said – we opt with beakr because our services do not demand such a degree of control.

View fiery “Hello, World!” example

Shiny

Shiny is a full suite package that makes it easy to build interactive web apps straight from R.

Features
  • Included bootstrap GUI API
  • A popular choice supported by RStudio

Shiny(CRAN, GitHub) is more than a web framework — it is an ecosystem that includes the Shiny package and the Shiny Server. They are tied together to make Shiny an awesome tool for creating GUI web applications and dashboards with R. Not to mention it is loaded with pre-built features that work really well with each other.

Here at Mazama Science, we like to use Shiny to develop web applications, documents, and dashboards. However, sometimes we demand simple and reliable web-services without the need for so many niceties and beakr fills that gap.

View Shiny “Hello, World!” example

Conclusion

These are only a few of the web frameworks that exist for R and this survey is not meant to be an exhaustive review of any one of them — these are just a few of our quick findings. Each of these frameworks is pretty full-featured and they can likely be used interchangeably for most projects. However, the small differences that define each framework are important and developers should do their own review of functionality before any starting any project.

For our typical use case at Mazama Science — creating R-based, modular web services — beakr is an excellent fit as it allows us to easily create a web service that responds to requests from other parts of a larger web-based data visualization system. Web services based on beakr have proven to be quite robust and are used operationally by the US Forest Service in their wildfire smoke air quality site which can see thousands of hits per hour during wildfire season.

— Mazama Science

To leave a comment for the author, please follow the link and comment on their blog: R – Blog – Mazama Science .

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)