Chapter 4 The Wider Ecosystem & Tools

4.1 Integrated Development Environments, or IDEs

As a scripting language, it’s possible to write R code in any text editor. However, as your codebase becomes larger, it becomes increasingly helpful to use a proper Integrated Development Environment (IDE). An IDE may offer syntax highlighting, making the code quicker and more straightforward to read; code completion, where the IDE suggests functions and so on as you begin to type their names; integration with a version control system; an integrated debugger; and a host of other features besides.

Many advanced text editors and IDEs support R, including Atom, VSCode, Sublime Text, Eclipse (via the StatET plugin), Vim and Emacs (via the ESS extension). Some people are happy using these tools, though the vast majority prefer a more fully fledged IDE, and there are currently three main options in this space:

4.1.1 RStudio

The RStudio IDE, from the company also called RStudio, is almost the de-facto standard IDE within the community. It was written from the ground-up with R users in mind and has an extensive feature set. The fact that RStudio develop both the IDE and many of the community’s most used packages has meant that the development team have been able to surface additional functionality within the IDE itself. For example, the IDE has a graphical connection interface that directly interfaces with the sparklyr package for working with Spark clusters. RStudio also has a server based version of the IDE that can be accessed and used via a web browser, so nothing needs to be installed on the client device.

The IDE is available in both open-source and commercial versions and works on Mac, Windows, and Linux.

4.1.2 Visual Studio (Using “R Tools for Visual Studio”)

Visual Studio is a powerful IDE with a long history and has recently had the R treatment too. There is an option in later versions to install “R Tools for Visual Studio”, which installs all the features you’d expect for working with R. In addition, it also has the ability to connect directly to a remotely running R session on a SQL Server 2017 or above, which means it can be used to drive sessions on much more powerful hardware than is usual for an end user computing device.

Visual Studio is available for Windows and MacOS, and is available in community and commercial versions. For licensing information please check the website for more details.

4.1.3 Jupyter

Jupyter is a little different from the other IDEs listed here, in that it only supports the “notebook” format of development. In the notebook format, code is executed in chunks and the results of the execution of that code is displayed immediately underneath. Jupyter has its roots in the Python community and is very popular there. It has since broadened out to support other languages – including R – though R use is not yet as polished as Python.

4.2 Web Apps in R with Shiny

Many people encountering R for the first time will be introduced to it through a Shiny application. Shiny is a framework for developing interactive web applications in R and can harness the powerful statistical and graphical capabilities of the language. Using Shiny, an R user with no real knowledge of web development can develop powerful interactive web applications – referred to as Shiny apps – with relative ease and no knowledge of HTML, CSS or JavaScript.

Since Shiny apps require R to run, in order to publish them, they need their own server software. As Shiny is another RStudio project, they also have the server side software required to publish these Shiny apps to end users. There are a couple of options for this, namely Shiny Server and RStudio Connect.

Shiny Server is open-source server software built for running Shiny apps. It does not have a great deal in the way of features, but what it does, it does very well. It allows a user to publish the Shiny apps that they’ve written to an always-on server system. Those apps can the be accessed by their end user community. For example, a shiny app could be written that provided a sales forecast, which could be published using Shiny Server and accessed by the management team at any time of the day or night and all without them having to know anything about R at all. If you would rather not stand up your own shiny server, you can check out shinyapps.io which provides both free and paid plans for hosting shiny applications.

If you are a professional organization which requires features like controlling access to individual apps with passwords, the ability to scale to handle larger audiences, or the ability to control resource consumption you can checkout the commercial version, Shiny Server Pro, or the more recent addition RStudio Connect.

RStudio Connect is the next step in the evolution of the Shiny Server Pro product, aimed at greatly enhancing performance as well as easing administration. In addition to serving Shiny apps, Connect can be used to publish reports written with RMarkdown, is capable of hosting APIs written in R with the plumber package, and has other features such as the ability to generate reports on a schedule and email them to a group of end users. Connect also uses a lightweight process isolation technique to prevent individual applications from interfering with each other.