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 features 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 is a small package and minimal web framework for quickly developing simple and stable web-services.
- Simple & Stable to get up and running
- Programmatic tidy syntax
beakr (CRAN, GitHub) is a package 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. At Mazama Science, we use beakr because it offers a simple and no-fuss back-end that we know and can rely on.
plumber is a package that allows you to create a web API by decorating your existing R code with special decorator comments.
- Only requires a decorative comment to expose endpoints
- Large community
- Supported by RStudio
The plumber package is targeted at those who have R code with a well-defined API and who want to make that API available as a web service. This makes plumber an excellent package for exposing R code that already exists. This 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.
Ambiorix is an unopinionated web framework package for R and is designed to be flexible and extendable.
- Extensions! (Generators template extensions, CLI support)
- Websocket support
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 toward an official release!
Fiery is a flexible and lightweight framework for building web servers in R with explicit control.
- Complete control of server life-cycle events
- Modular design
fiery (CRAN, GitHub) is designed to give you explicit control of server life-cycle events and the ability to flexibly handle them. It’s a framework that defines itself as lightweight with modularity and control in its design. We think fiery is best suited for developers who 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 exists for R and, as such, has some technical overhead. That being said, we like beakr because our services do not demand such a degree of control.
Shiny is a full suite package that makes it easy to build interactive web apps straight from R.
- 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. These are tied together to make Shiny an awesome tool for creating GUI-driven 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 occasionally use Shiny to develop web applications, and dashboards. However, we often only need simple and reliable web-services without the full suite of features and extra technical overhead that come with a Shiny app. In those cases, beakr is an optimal solution.
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