FES 720 Introduction to R

LAB: Plotting Colours

This is the lab associated with the lecture and lesson on Plotting Colours in R.

Please upload your final completed lab on the Assignments page in Canvas, as per the instructions below.

You are welcome and expected to ask for help from the instructors if you get stuck: Please also come to the R Bootcamp on Friday—there is coffee and snacks!


Sparrows

Download the full sparrow dataset

dat <- read.table(file = "http://www.simonqueenborough.info/R/data/sparrows.txt", header = TRUE)
  1. Display the first 9 rows of the data.

  2. Display the final 3 rows of the data.

  3. Calculate the mean Head size and Tarsus size for both species x sex combination.

  4. In a 2-panel figure of two boxplots, plot Tarsus as a function of sex in one panel, and plot Head as a function of sex in the other. Make sure that each sex has a consistent color.

  5. Plot the data again, but instead of boxplots, use stripcharts to illustrate all the data points. Superimpose the mean values on top and add error bars. Ensure that the data points are paler and the summary data stand out. Check the bestiary for details on stripcharts.

  6. Plot Head as a function of Tarsus. Ensure that the points for each sex and species are different but consistent (e.g., circles for species 1, squares for species 2, empty for males, filled for females). Make some good use of colour.


How to write up your answers

Please check the help page for a reminder, if you need to.


Updated: 2017-11-10