Exercises for 2.2: Statistical graphics

Preliminaries

  • load the driving.Rdatafile.
  • type head( driving )to look at the first few observations
  • load the following packages: lsr
load( "~/Work/Research/Rbook/workshop_dsto/datasets/driving.Rdata")
head( driving )
library(lsr)

Exercise 2.2.1: Scatter plot

  • Draw as scatter plot of age (age) against RT on the first test (rt_time1)
  • Customise the plot: give it a title, x-axis and y-axis labels, and maybe change the marker.

Exercise 2.2.2: Box plots

  • Draw box plots for age, broken down by distractor
  • Make it pretty

Exercise 2.2.3: Histograms

  • Draw a histogram showing the distribution of the number of errors made at the first test.
  • Make it pretty

Exercise 2.2.4: Bar graphs

  • Draw a bar graph showing the number of people who were tested under each of the three distractor conditions
  • Make it pretty

Exercise 2.2.5: Bar graphs of means with error bars

  • Plot the mean number of errors at time 1 by distractor type, with 95% confidence intervals
  • Plot the mean number of errors at time 1 by distractor type and by whether the test was taken during peak hour traffic, with 95% confidence intervals
  • Redo the last plot, but switch the order of the two grouping factors in the formula

Exercise 2.2.6: Save an image

  • Use the Rstudio tools to save one of the plots that you’ve drawn