forked from jmledford3115/datascibiol
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lab5_hw.Rmd
70 lines (44 loc) · 2.62 KB
/
lab5_hw.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
---
title: "Lab 5 Homework"
author: "Joel Ledford"
date: "Winter 2019"
output:
html_document:
theme: spacelab
toc: no
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## Instructions
Answer the following questions and complete the exercises in RMarkdown. Please embed all of your code, keep track of your versions using git, and push your final work to our [GitHub repository](https://github.com/FRS417-DataScienceBiologists). I will randomly select a few examples of student work at the start of each session to use as examples so be sure that your code is working to the best of your ability.
## Load the tidyverse
```{r message=FALSE, warning=FALSE}
library(tidyverse)
```
## Mammals Life History
Let's revisit the mammal life history data to practice our `ggplot` skills. Some of the tidy steps will be a repeat from the homework, but it is good practice. The [data](http://esapubs.org/archive/ecol/E084/093/) are from: *S. K. Morgan Ernest. 2003. Life history characteristics of placental non-volant mammals. Ecology 84:3402.*
1. Load the data.
2. Use your preferred function to have a look. Do you notice any problems?
3. There are NA's. How are you going to deal with them?
4. Where are the NA's? This is important to keep in mind as you build plots.
5. Some of the variable names will be problematic. Let's rename them here as a final tidy step.
rename(
genus = Genus,
wean_mass = `wean mass`,
max_life = `max. life`,
litter_size = `litter size`,
litters_yr = `litters/year`
)
##`ggplot()`
For the questions below, try to use the aesthetics you have learned to make visually appealing and informative plots. Make sure to include labels for the axes and titles.
```{r}
options(scipen=999) #cancels the use of scientific notation for the session
```
6. What is the relationship between newborn body mass and gestation? Make a scatterplot that shows this relationship.
7. You should notice that because of the outliers in newborn mass, we need to make some changes. We didn't talk about this in lab, but you can use `scale_x_log10()` as a layer to correct for this issue. This will log transform the x-axis values.
8. Now that you have the basic plot, color the points by taxonomic order.
9. Lastly, make the size of the points proportional to body mass.
10. Make a plot that shows the range of lifespan by order.
## Push your final code to [GitHub](https://github.com/FRS417-DataScienceBiologists)
Make sure that you push your code into the appropriate folder. Also, be sure that you have check the `keep md` file in the knit preferences.