Before we Start


Figure 1

RStudio extends what R can do, and makes it easier to write R code and interact with R.

Figure 2

automatic car gear shift representing the ease of RStudio

Figure 3

A picture of RStudios interface
RStudio interface

Figure 4

A picture showing the layout of a good working directory as described above
Example of a working directory structure

Figure 5

Packages pane
Packages pane

Figure 6

Install Packages Window
Install Packages Window

Introduction to R


Starting with Data


Figure 1

A 3 by 3 data frame with columns showing numeric, character and logical values.{alt = ‘A 3 by 3 data frame with columns showing numeric, character and logical values.’}


Data Wrangling with dplyr and tidyr


A couple of plots. And making our own functions


Figure 1


Figure 2


Figure 3

Two new things happens here. First, we are using a new way of telling the plot function what relationship we want to visualise. The function notation y~x, tells the boxplot function that we want to visualise y as a function of x. In this case we want to visualise the number of people, as af function of the wall type. Secondly, we use a boxplot. A boxplots shows the distribution of the values on the y-axis. The median value is indicated by the solid bar. The box encapsulates 50% of the observations. Its upper and lower borders represents the interquartile range (IQR). The whiskers on the plot - here only the upper whiskers are shown due to the nature of the data, represents the range of the data. The distance from the upper part of the box, to the whisker is 1.5 times the interquartile range. The dots that we see for muddaub and sunbricks are outliers. Observations that lies so far from the rest of the observations, that we consider them as outliers.


Figure 4


What is the next step?