What is R-Shiny?
R is a statistical (open source) programming language which is designed to create high-quality data visualizations. It’s the perfect tool for performing mathematical calculations on R. Many people often use it to create graphics for publication-worthy articles.
However, what most don’t realize about R is that it can be used on a server through a application called Shiny. Shiny is a tool which is designed to allow you to build web apps directly on a server using this software package. It’s used to create a standalone app, designed to be used for analysis.
R-Shiny is commonly used to create beautiful, fully modern data visualizations. It’s an impressive and powerful tool for this purpose. The best part is that you don’t have to be a formally trained web developer in order to be able to use this software package.
Setting up a Shiny Server
Shiny apps are commonly hosted on the R-Studio server. You can download the Shiny Server open source version with the use of a few linux commands. There is also a paid version of the Shiny server available if you are looking for more functionality. Alternatively, if you would prefer, you can upload your app to the cloud at the R-Shiny shinyapps.io server.
Supported Operating Systems and Hardware
Shiny server is a open-source package. There are pre-compiled packages available, but these can only be installed on: Red Hat / CentOs, Ubuntu, or openSUSE/SLEs. Unfortunately, if you are using a standard Mac / PC desktop operating system, then there is no option available to you for installing Shiny. If you’re using a non-supported package, then you do have the option of using the SUDO package installer to install Shiny on your machine. Furthermore, only a 64 Bit processor is able to support the Shiny Server package.
Installing Shiny Server from the Binary on a Supported Machine
If you are installing the Shiny binary version on a supported Linux distribution, you are in luck. The process for installing Shiny is very simple.
Before you install the Shiny server, there is one thing to keep in mind. Three components to the server are required to install the Shiny package. First, you have to install R and Shiny R. Both R and Shiny R can be installed with the sudo command, depending on your distribution. After you have installed R and Shiny R, you’ll install the R Studio server to complete the process.
Here are the installation instructions for each distribution:
Installing the Shiny Server on An Unsupported Distribution
To install Shiny Server on an unsupported distribution, you’ll have to have a few prerequisite packages: cmake, python 3.6, gcc, g++, git, and R-Base-Devel, cmake. Find more info on the Shiny Github page.
Here is the SUDO command to install Shiny on your machine:
sudo su – -c “R -e \”install.packages(‘shiny’, repos=’https://cran.rstudio.com/’)\””
Source: R-Studio’s Github Page
Once you have installed the prerequisite packages and the Shiny package on your system, clone the Github repository into a temporary directory on your local machine.
Here is a basic overview of the required steps, which can be found on the Github page:
1. Install the node.js package which is included with the clone
2. Create a reference node by adding the binary directory to a PATH variable
3. Run the make command to compile the downloaded code
4. Use sudo make install to create an installation at specific a location on the machine
5. Copy the config file from the installation directory
Starting and Stopping
Once you have successfully installed the Shiny Server on your local Linux machine, you’ll have to further configure it. As the software package is a server, you will need to use the start and stop commands whenever you would like to use the server. For Redhat, Ubuntu, and SLES installations, use the:
sudo systemctl start shiny-server
sudo systemctl stop shiny-server
commands to start and stop the server, respectively.
The configuration file at the /etc/shiny-server/shiny-server.conf on the shiny server is designed to allow you to configure very specific settings on the server. Most people can work with the default configuration file, but you may want to make a few changes.
If you would like the server to run on a different port, look for the listen line in the config file and change the number to the port you would like the server to listen on. For example: listen 3838; implies that the server is configured to run on port 3838. Many of the other commonly used settings are typically reserved for expert users. Please visit the configuration guide for more information.
Get Started Building Apps
Once you’ve installed the server, you can connect to it with the RStudio application once you have installed the appropriate packages to connect!