Converting R code to API

I just came back from a local R meeetup and a great talk by Mark Sellors from Mango Solution. This is first time I heard about Plumber, which allows to convert your existing R code into an API by adding a few lines of comments to the existing code - very similar in approach to what roxygen auto-generation of user documentation directly from the source code.

Plumber is using REST API, popular with web applications and in simplification meaning that client don’t need to know anything about API structure.

What it means in practice is that by adding few lines of #* comments to your R code you make it API ready. This code can be then mounted locally or on server, parsed and ready to receive calls on the specified port. It is really that simple as Jeff Allen presentation from EARL 2015 shows.

This API can output values and graphs as well, as this example shows, which makes it interesting alternative to shiny, where everything is contained inside the app. It does comes with few limitations though (all kudos to Mark Sellors, I am merely coping my notes from the meetup):

I plan to run some quick tests later this week following examples from Mark and Jeff. Will keep you posted.

If you liked this post, you can Tweet about it or Follow me on Twitter