The exercises for the course have been compiled here.
Outline of things to cover:
- Create Rproj and folders "data_output" and "scripts"
- Intro
- skip factors
- exercises 1.1 and 1.2
- data.frames
- use
read_csv()
from the beginning to simplify things
- don't spend too much time here, main thing is to explain
[rows, columns]
for subset and $
to access column
- exercise 1.3
- dplyr
- skip spread/gather (covered in extra RNAseq lesson)
- exercises 2.1, 2.2, 2.3
- Do exercise 2.4 with students to save time
- ggplot2:
- skip themes and customisation (simply mention them at the end)
- extra: see note below to mention factors
- exercises 3.1-4 (if time is short do some exercises together)
note: extra material for ggplot2
section
So that students intuitively understand factors, introduce them in the plotting
section.
For example:
When doing this plot:
surveys_complete %>%
ggplot(aes(sex, hindfoot_length)) +
geom_boxplot()
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:
surveys_complete %>%
mutate(sex = factor(sex, levels = c("M", "F")))
ggplot(aes(sex, hindfoot_length)) +
geom_boxplot()
Exercise 3.4 applies this concept again.