Week 1 practice

Some of the materials for Week 1 Workshop can be run live here. This provide an interactive playground to try out your code.

Important

You will still be expected to download the workshop files each week, and run them in the workshops. The aim of this interactive environment is get you started with coding in R, and improve your familiarity. You are not expected to memorise any of the code syntax, the aim is to improve your confidence.

The tidyverse package has been loaded in this environment. It consists of many different packages. We will only be using ggplot2 here:

Summarise the data. The data mtcars is available in the base version of R. we can use the function summary to do this.

Including Plots

You can also embed plots, for example:

Your first plot

Lets look at a different dataset - the mpg dataset is included in R:

Create a simple plot:

EXERCISE: Look at some summary statistics. What function will you use on the mpg data to do this?

Plot using colour by cty:

EXERCISE: Color the points by the class variable.

Hint 1

Copy and paste the previous code which colours by ‘cty’. What change do you need to make?