A R & RStudio
As explained on the welcome page, we will be using the statistician’s favourite tool, R (pronounced like the letter, not an enthusiastic pirate 🏴☠️!)
On this page we cover in detail the three ways you can run R and RStudio
- Option (i) Github Codespaces (recommended)
- Option (ii) Durham AppsAnywhere
- Option (iii) Your own computer
Option (i) Github Codespaces (recommended)
You can run a custom image designed for this course on a free Github cloud server. This enables running an RStudio session through a web browser, which eliminates the variability in personal laptop and University lab computer setups. This is not compulsory, but is likely to make life easier and having a Github account may be very useful to you if you continue with more advanced programming and data science.
To use this approach:
Make sure you have a Github account (these are free). For a step-by-step guide to creating an account, click here, and come back when complete to continue to step 2.
To ensure your session does not time out within the duration of a lab, we need to update one of the settings. Click this link: https://github.com/settings/codespaces#default-idle-timeout-header, sign in if necessary, and update the setting entitled “Default idle timeout” to 70 minutes and click “Save” (guaranteeing it stays on for the whole lab). It should look like this after:
You don’t need to repeat these first two steps again. In future, proceed to step 3 to get going for a lab.
Click the Github Codespaces link, which can be found near the bottom of the left hand menu bar on every page of these notes.
If you prefer following a video, you might want to skip to the 3 demo videos, explaining first-time setup, shutting down after the lab, and later resuming a Codespace.
If the page has the bold text “No codespace to resume” near the centre, then click the green “Create new codespace” button. IMPORTANT: if you do not see that, but instead see “Previous session found”, you already have a codespace and should click on it to resume. Failure to do this will create more and more codespaces and exhaust your allowance prematurely!
It may take some time to start up (and be quicker when resuming a previous session). Eventually you will get a screen looking like this. Click the Ports tab, then the wireframe globe to launch RStudio:
You can now execute commands etc and this will run remotely on the server via your browser. If you login from another computer, you’ll be able to resume the same session there. You’ll know if you’re in the right place if it looks like this:
When you are finished, press the red standby button at the very top right of the page before closing the tab. Then, when back to the original launch screen, click the “Codespaces” button at the very bottom left, followed by “Stop Current Codespace” in the menu that pops up. Wait until it confirms with a page simply stating “Codespace is stopped”, after which you can quit completely.
You may find it easier to follow the following silent videos which demonstrate what you should see as you go through the three main steps (first time setup, shutdown, and later resuming).
Codespaces first run
The following (silent) video shows you how to do the first run of Codespaces to get RStudio working. NOTE: after the first time, you should follow the instructions in the resuming Codespaces video below.
Shutdown a Codespace
The following (silent) video shows you how to cleanly and correctly stop a Codespace after you finish work. You should follow this procedure every time you work on a Codespace. Note that your work will be saved by doing this. When you want to come back and work some more, you should follow the instructions in the resuming Codespaces video below.
Resuming a Codespace
The following (silent) video shows you how to resume a Codespaces. NOTE: if you start a new one instead, you will quickly exhaust all your free allowance, so be sure to resume each time!
Git-what now? 🤪
You may be wondering what this ‘Github’ malarkey is! Well, Git is a powerful software version control tool, and Github is a cloud service providing full software development lifecycle services. These are beyond the scope of a 2nd year undergraduate course in R and data science, but if you are serious about applied statistical research or data science as a career you will almost certainly eventually need to learn them. If you would like to understand more about why you would want to learn them, I recommend the excellent preprint provided by Dr Jenny Bryan, entitled “Excuse me, do you have a moment to talk about version control?”. She also has fantastic online book “Happy Git and GitHub for the useR”. More generally, an excellent resource on these (and many other) important topics for a career in data science, outside of just the mathematics and programming we cover here, can be found in “The Turing Way”.
Option (ii) Durham AppsAnywhere
Both R and RStudio are available on all CIS maintained machines via AppsAnywhere. You can also run AppsAnywhere on your own machine, though the performance can be poor from outside Durham if your internet is not fast enough.
On a CIS maintained computer, just launch AppsAnywhere directly. From home you can visit the “hosted desktop” site to run the software. For more help, see the CIS help pages.
Option (iii) Your own computer
If you have your own computer, I highly recommend trying to install the software for yourself. This is because when you go on to do a final year project, or use R in industry, there won’t always be a setup of R and RStudio done for you. Installing it yourself enables you to play around in the comfort of your home, or anywhere you don’t have internet access, and is just generally a good skill to acquire. Having said that, do not waste precious lab time trying to get it to work … use option (i) or (ii) if you’re stuck and feel free to ask me for help outside the lab.
The links to download R and RStudio (you need both!) for your own computer are:
A detailed walk-through is provided in the video guides below for Mac OS/Windows (there are too many versions of Linux … but feel free to ask for help if you get stuck!)