Exploring the data
One of the first things to do with new datasets is to plot it prior to analysis. During this exercise, you will plot the data using ggplot2
and create a publication quality figure. This will help you to see the data.
This data examines if two different drugs change the amount of sleep individuals get. The response variable of interest is the amount of extra
sleep a patient gets. The predictor variable is the drug group
. The ID
of each patient allows us to do a repeated measures analysis. This is a random-effect intercept and corresponds to the baseline effect of giving a person a sleeping drug. We do not care how much an individuals sleeps in this case, only the change in sleep of the groups.
The data.frame sleep
contains these variables.
This exercise is part of the course
Hierarchical and Mixed Effects Models in R
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Plot the raw data
ggplot(data = ___, aes(x = ___, y = ___)) +
geom_point()