First of all, what is R and why do we use it?
R is a programming language developed by statisticians Ross Ihaka and Robert Gentleman. It is currently maintained by the R Core Team.
R comes with many useful tools for statistical analyses and additional tools can be installed as packages from CRAN – R’s central software repository – and there are many packages available for different statistical analyses, plotting and visualisation.
You can combine existing functions with your own written functions by creating R scripts – making it an extremely useful and flexible environment for data analysis.
Getting started
Step 1: Check you have R on your computer.
Go to your terminal (shortcut is CTRL + ALT + T in Linux)
Type ‘R’
If you get something like this:

you already have R installed, If you don’t, follow the instructions here.
So what is Rstudio and why do we use it?
Rstudio was founded by J.J.Allaire and is a free and open-source program which is widely used by researchers across academia and industry. It provides an integrated development environment where you can write your code, run it and view the output of your analyses all in the same place.
Step 2: Download R studio
Go to the rstudio website and find the download suitable for your operating system.
Step 3: Open up Rstudio
Below is a screenshot of what Rstudio looks like when it starts up:

Step 4: Set the working directory
To keep things simple I usually work out of a single directory when working on a project using R. In this directory I save the script I’m writing, the test data and any notes.
Before you start you need to tell Rstudio where to find your working directory so that it can find your script and data files, to do this go to Session > Set Working Directory > Choose Directory (see below) then select the folder you want to work in.
