RStudio Shiny Apps tutorial

Much of the first parts of each practical will be based on Shiny Apps - these are ineractive applications that allow the user to manipulate settings and see the resulting effects immediately. You will be working with Shiny Apps which are aimed to help you better understand how each of these population ecology equations work. Each of the Shiny Apps used in this course will be made up of a dashboard containing sliders or buttons which you can use to dynamically adjust the output of the figures in the app’s main panel.

In order to get these applications to work you will need to download an app.R file. These can be accessed by clicking on a link that looks like this:

Download the exponential growth: Births and deaths app here

You will find these links scattered throughout the practical webpages just before a set of questions relating to the section which you have just read through. When you see the bold text and download link, click on the here text. This will take you directly to a DropBox folder containing the Shiny App’s app.R file. Once you have found the relevent app.R file, download it to you local computer and save it in a logical and descriptive file structure where the name of the folder describes the app. Keep each app.R file in its own personal folder. This is important as the app.R file name cannot be changed - if you do rename the app.R folder the app will not run. As you cannot change the app.R file name the best way to keep track of your files is by placing it in a unique folder.

Once the app.R file has been downloaded to your computer and saved to your harddrive in a safe and logical place you can open the app in RStudio. The file will open as a new script. Do not worry about the contents of this script and be sure not to mess with any of the code. These apps are quite sensitive and slight changes to the code will cause the app to break. If something does go wrong with your app.R file you can always download the file later. When you open an app.R file in RStudio, RStudio will automatically detect that this script can run as an app. The RStudio window will then change to having a Run App button in the top right corner of the script view sub-window.

When you click this button RStudio will begin compliling the app. Before the app can be compiled completely RStudio needs to load any packages that might be missing. There is code in each of the apps that will run a quick check to see whether the computer you are working on has the packages required for the app being loaded. If the packages are there then in a couple of seconds you should see you app and you can then carry on answering the questions. If the packages have not yet been installed on your computer, R will then install the packages and then load the packages. This may take a few minutes - please be patient. The first few apps that you use will likely need to install a few packages before the app will run but after the first few apps have been loaded just about all the required packages will have been loaded on your computer.

Please be awear that you can run these Shiny App files without being connected to the internet provided you have all the require packages already installed from CRAN. If you do not have these required packages installed you will need an internet connection to run these apps.