These labs test and build on the material presented in the SWIRL lessons.
Scroll down or click here to to check how to submit them.
Using the sparrow data set.
dat <- read.table(file = "http://www.intro2r.info/data/sparrows.txt", header = TRUE)
Show the following:
i. the number of males and females of species SESP, ii. the number of males and females of species SSTS, iii. the number of individuals in each species that are male, iv. the number of individuals in each species that are female.
Plot the distribution of Head for (i) males and (ii) females.
Plot Wingcrd as a function of (i) Tarsus and (ii) Head.
Plot (i) Tarsus as a function of Sex and (ii) Head as a function of Sex.
Using the sparrow data set.
dat <- read.table(file = "http://www.intro2r.info/data/sparrows.txt", header = TRUE)
Show the following:
i. the number of males and females of species SESP, ii. the number of males and females of species SSTS, iii. the number of individuals in each species that are male, iv. the number of individuals in each species that are female.
To help aid comparisons, make sure that the y axes for each plot has the same range.
Each plot should have x and y axis labels in bold.
Plot the distribution of Head for (i) males and (ii) females.
Ensure that males and females are different colours.
Each plot should have axis lines wider than the default width and horizontal y-axis numbers.
Plot Wingcrd as a function of (i) Tarsus and (ii) Head.
Differentiate each species by colour and symbol.
Ensure that the tick marks point inwards.
Add axis labels with units in parentheses (you can make up what the units are, because they are not specified in the data).
Plot (i) Tarsus as a function of Sex and (ii) Head as a function of Sex.
Make sure that each sex has a consistent color.
Plot (i) Tarsus as a function of Sex and (ii) Head as a function of Sex.
Add points for the raw data.
Calculate the mean Head size and Tarsus size for both species x sex combination.
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).
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).
Trees in a 1-ha plot on East Lansing, MI, USA. Colours indicate different species; size of symbol indicates DBH.
# Read in the data
dat_tree <- read.table("http://www.intro2r.info/data/treespecies_cleandata.txt",
header = TRUE, sep = '\t')
Use colour and symbols to distinguish species.
Scale symbol size to DBH.
Use nice axis labels and ensure that tick numbers are horizontal.
Use wider (i.e., thicker) lines.
Label the axes with units.
Make a single figure containing two boxplots of tree DBH, one for alive and one for dead trees.
Fill each box a different colour.
Add an arrow and a label identifying the species of the outlier in the boxplot of dead trees.
Make a similar plot to the boxplots above (q3), but instead of boxes, display the datapoints for each tree. Ensure that these points are a paler shade of grey.
Overlay segments to display the SE of the mean for alive and dead trees.
Overlay larger and darker points indicating the mean DBH of alive and dead trees.
You will need to write R code to answer each of the questions.
Please format your answers as follows:
Copy and paste each question, commented out. This ensures that we know which answer corresponds to which question.
Write your R code answer below each question.
It should look something like this:
# LAB: Unit 1. Lab 1
# Your Name # Put your name here
# 1. Add 7 and 3,456.
7 + 3456
# 2. Assign this value to an object
x <- 7 + 3456
Log into Canvas.
Go to the Assignments page.
Under ‘Labs’, you should find the correct assignment.
Copy and paste your R code into the text box.
Click ‘Submit Assignment’.
You are permitted to submit your answers as many times as you like within each Unit.
Answers will be graded two or three times a week and re-opened if you submit early.
Each lab will close at its respective deadline (see Canvas).
Final grades for each lab will be computed and entered into the Canvas gradebook at the end of each Unit.