Adult vs Newborn Size (Graphing)
Larger organisms have larger offspring. We want to explore the form of this relationship in mammals.
Check to see if
Mammal_lifehistories_v2.txt is in your working directory.
If not download it
from the web.
This is tab delimited data, so you’ll want to
sep = "\t" as an optional argument when calling
how we indicate a tab character to R (and most other programming languages).
When you import the data there are some extra blank lines at
the end of this file. Get rid of them by using the optional
nrows = 1440 to import only the first 1440 rows.
Missing data in this file is specified by
-999.00. Tell R that
these are null values using the optional
na.strings = c("-999", "-999.00"). This will stop them from being plotted.
- Graph adult mass vs. newborn mass. Label the axes with clearer labels than the column names.
- It looks like there’s a regular pattern here, but it’s definitely not linear. Let’s see if log-transformation straightens it out. Graph adult mass vs. newborn mass, with both axes scaled logarithmically. Label the axes.
- This looks like a pretty regular pattern, so you wonder if it varies among different groups. Graph adult mass vs. newborn mass, with both axes scaled logarithmically, and the data points colored by order. Label the axes.
- Coloring the points was useful, but there are a lot of points and it’s kind
of hard to see what’s going on with all of the orders. Use
facet_wrapto create a subplot for each order.
- Now let’s visualize the relationships between the variables using a simple
linear model. Create a new graph like your faceted plot, but using
geom_smoothto fit a linear model to each order. You can do this using the optional argument
method = "lm"in