A sample of tutorials demonstrating data analysis in R
Getting Started
- Getting Started with R
- Importing Data into R
- Organising Data in R
- Manipulating data in R
- Visualising data with R
- Examples of quantile-quantile plots
Starting Data Analysis
- Distributions
- Sampling a Population
- Statistical modelling of data
- Describing a model with an R formula
Data files
Here is an overview of the datasets used in these worksheets
To install R
The homepage for downloading the latest R software is(opens in a new window)http://cran.r-project.org/.
Below we provide shortcuts directly to the installer files for Windows, Mac and Linux operating systems. If the downloads are slow you can select your nearest(opens in a new window)mirror site from this list
R for Windows
The installer for the latest version of R for Windows can be downloaded from (opens in a new window)http://cran.r-project.org/bin/windows/base/. The latest version will runon Windows XP and later (including 64-bit versions of Windows).
R for Mac
The installer package for the latest version of R for Macs can be downloaded from (opens in a new window)http://cran.r-project.org/bin/macosx/.
R for Linux
To install on a Linux machine go to(opens in a new window)http://cran.r-project.org/bin/linux/and select your distribution of linux from the list. Installation instructions for each Linux ditribution can be found in a README file.
To install RStudio
(opens in a new window)Rstudiois a user interface for R that has a free open source version available for Windows, Mac and Linux operating systems.
To install RStudio go to(opens in a new window)https://www.rstudio.com/products/rstudio/download/and select the installer for your operating system under the "Installers for Supported Platforms" section. To complete the installation, save and open the installer and follow the installer's instructions.
To install a package for R
The taught modules require three packages to be installed that do not come with R's base distribution: ggplot2, tidyr and emmeans. Here we describe how to install ggplot2. The other packages can be installed using the same approach.
(opens in a new window)ggplot2is a graphics package for R that adds to R's built-in graphical functions.
There are two ways to install ggplot2.
Method using RStudio
Follow steps 1-4 (see image below)
- Open RStudio, click on the Packages tab in the bottom right panel
- click on the install icon
- type "ggplot2" in the dialogue box underneath "Packages (separate multiple with space or comma)"
- click the install button
Method using just R
Open R and in the console window type
install.packages("ggplot2")