Open tavareshugo opened 5 years ago
Rough timings for sessions:
Day 1 AM:
Day 1 PM:
Day 2 AM:
Day 2 PM:
Part two, updating existing graph to add sex, does not include a solution.
yearly_diversity <- surveys_complete %>%
group_by(sex, year, plot_type) %>%
summarise(n_species = n_distinct(species_id)) %>%
ungroup()
yearly_diversity %>%
ggplot(aes(year, n_species)) +
geom_line(aes(colour = plot_type)) +
facet_grid(sex ~ .) +
labs(colour = "Plot Type", x = "Year", y = "# species")
To make it easier for us, the exercises for the course have been compiled here.
Some notes on the things to cover:
read_csv()
from the beginning to simplify things? (optional, but I find it useful to keep consistency across the course)[rows, columns]
for subset and$
to access column. For example I personally avoid showing the 4 different ways to access a column listed in the materials (usually it's quite confusing for beginners)note: extra material for
ggplot2
sectionSo that students intuitively understand factors, introduce them in the plotting section.
The narrative goes something like this:
When doing this plot:
What if we want to change the order of the x-axis labels to be "M" first?
Then we need to learn about factors, which are a special way that R has to encode categorical variables.
Let's look at factors using a simple example first. Then go through the example of the course materials here, but only the very first section of it.
From there, jump back to the plotting problem and resolve it:
Exercise 3.4 applies this concept.