This tutorial will aid you in:
R is the free software that will be used for running the different “apps” created. It is able to be run on Windows, Macs, and Linux machines. For more information about R, go to the R homepage.
If you are going to install R yourself from the internet, go to https://cran.r-project.org/. From that page, you can choose to install it for Windows, Mac, or Linux machines. Go to the page for your machine and, download, and run the installer.
Once you have installed R, you can launch the the software by searching in your operating system for the program and opening the R icon. Should the installation be successful, you should see the main R window which is called the console (see figure below). This basic graphic user interface (GUI) is were you can type commands and get results of executing these commands immediately.
RStudio is an integrated development environment (IDE) for R, which makes it easier to write, edit, and run code in R. It also makes it easier to run R Shiny apps locally on your own machine.
If you are installing RStudio from the internet, go to their website for downloading the product (https://www.rstudio.com/products/rstudio/download/). Click the button to download the free Desktop version. This will automatically scroll the webpage down to choose which version to install. Choose the installer that is compatible with your machine (most likely the Windows or the Mac version). Download the and run the installer.
Once it is downloaded and installed, find the program RStudio on your machine and run it.
R Studio is a very powerful, freely available, integrated development environment (IDE) developed to facilitate code development and execution through the inclusion of an R console and syntax editing capabilities. Additionally, the platform includes tools for plotting, debugging, work-space management, and code history tracking.
Once installed, proceed to open R Studio. The first time you start R Studio you will see three regions in the interface (see below):
The final part that this tutorial will cover is how to install packages for R, using R Shiny.
First, open RStudio. Then click File -> New File -> R Script. This should open up an untitled file in the editor window. In the editor you can write and run code, the code will run in the console located below the editor.
Packages allow you to download work that other people have done, so that you can build on top of them by using the various functions that other people have created. They only need to be installed once on a computer (as long as it is successfully installed) and they will become part of your library on your computer. From your library, you will then be able to load the package and use it.
If you are operating a machine that does not allow you to save things to your default drive (for example on a Windows machine, your C drive) you might have to do another step. This is common when working on machines where you are using a roving profile. If this is a case, please go to this next section which will show you how to choose where your library will be installed.
To install the package Shiny copy and past the following code into your R File you created in the text editor above. The code below is telling R to install a packaged called “shiny” and will also install any other packages that are needed for it to run.
install.packages("shiny", dep=T)
To run the code either highlight it, or click on that line. Then click on the “Run” button in the upper right of the text editor.
To check to see if the code is running correctly. We will first want to load the “shiny” packages. This can be done by copying and pasting the code below into the editor. Then, either highlight or click on the line and click the run button like you did previously.
library(shiny)
To see if the packages are working correctly, you can launch an example Shiny app by copying and pasting the below code into the editor and running the code.
runExample("01_hello")
What should happen is a new window will open up, similar to what is seen in the video below. This window that opens up allows you to use interact with the example data and manipulate it. Once it is up and running, you can close the window that opens up in order to stop the app from running.