- load data (part of the lme4 package)
data(sleepstudy)
head(sleepstudy)
Reaction Days Subject
1 249.5600 0 308
2 258.7047 1 308
3 250.8006 2 308
4 321.4398 3 308
5 356.8519 4 308
6 414.6901 5 308
- and build the graph using a linear model (method="lm" in the geom)
ggplot(sleepstudy,aes(x=Days,y=Reaction)) +
geom_point() +
geom_smooth(method="lm")