To submit this assignment, upload the full document, including the original questions, your code, and the output. Submit your assignment as a knitted .pdf. Please ensure the text on your .pdf does not continue past the end of the page.
Compare the mean biomass for grazedcontrol with that of rodentexclosure graphically in a line plot. What could explain the big dip in biomass year 2012? (0.75 marks) Hint: The published study might be able to help with the second question
Compare the mean yearly change in biomass for each species in a lineplot. (0.5 marks)
We’ve found that the biomass is higher in the sites with rodent exclosures (especially in recent years), and that the crowberry is the dominant species. Notice how the lines for rodentexclosure and crowberry are of similar shape. Coincidence? Let’s find out! Use a facetted line plot to explore whether all plant species are impacted equally by grazing. (0.75 mark)
The habitat could also be affecting the biomass of different species. Explore this in a line plot of the mean biomass over time. (0.75 marks)
Explore the relationship between species, habitat, and biomass in a box plot. (0.5 marks)
It looks like both habitat and treatment have an effect on most of the species! Let’s dissect the data further by visualizing the effect of both the habitat and treatment on each species by faceting the plot accordingly. (0.75 mark)
2. Customising plots (1 mark)
Create a ggplot theme object that makes five modifications to plot appearance. Save it this way so you can use it in other plots (including outside of this course). You can use the vignettes at the bottom of ggplot’s theme documentation to find arguments you might like to modify. Some components you might like to alter: panel.background to change the colour of the plot body (remember, colour alters plot element outlines and fill alters the body of plot elements), panel.grid to alter the plot grid, strip.text for facet box text, and legend.title to change the size of the text of the legend’s title. (0.5 mark)
Apply this theme to your plot from 1f and add labels (a title, colour legend title, x axis lable, and y axis label). (0.5 marks)
3. Visualising mammal size dimorphism (3 marks)
Download the “SSDinMammals.csv” file from Quercus, the course website, or Data Dryad. The original study2 is quite interesting!
Make a scatterplot with female mass on the x-axis and male mass on the y-axis. Plot a straight line with slope y = x (can use the abline geom) behind the mass data points. Make subplots according to Order, allowing free scaling of the axes. Apply the theme you made in question 2. (1 mark)
Calculate the proportional mass difference ([massM - massF] / massM) for all the rows in the data set. Separating the data by Order, create a boxplot of these proportional mass differences. Plot a horizontal line behind the data, with a y-intercept that would reflect no mass difference between sexes. Apply your theme from question 2. Finally, ensure the Order text is legible. (1 mark)
Improve your plot from 3b. Include points behind the boxplot that reflect the number of observations for each point (i.e. sizing by n_M or n_F). You should ensure these points are reasonably visible by using a variant of the point geom (look to the data exploration lecture’s section on boxplot augmentation) and specifying opacity. Visually differentiate the horizontal reference line from the data (using colour, for example). Label your axes and legend. (1 mark)
Olofsson J, te Beest M, Ericson L (2013) Complex biotic interactions drive long-term vegetation dynamics in a subarctic ecosystem. Philosophical Transactions of the Royal Society B 368(1624): 20120486. https://dx.doi.org/10.1098/rstb.2012.0486↩︎
Tombak, K.J., Hex, S.B.S.W. & Rubenstein, D.I. New estimates indicate that males are not larger than females in most mammal species. Nat Commun 15, 1872 (2024). https://doi.org/10.1038/s41467-024-45739-5↩︎