Intermediate Data Visualization with ggplot2
Rick Scavetta
Founder, Scavetta Academy
head(barley, 9)
yield variety year site
1 27.00000 Manchuria 1931 University Farm
2 48.86667 Manchuria 1931 Waseca
3 27.43334 Manchuria 1931 Morris
4 39.93333 Manchuria 1931 Crookston
5 32.96667 Manchuria 1931 Grand Rapids
6 28.96667 Manchuria 1931 Duluth
7 43.06666 Glabron 1931 University Farm
8 55.20000 Glabron 1931 Waseca
9 28.76667 Glabron 1931 Morris
ggplot(barley, aes(year, variety,
fill = yield)) +
geom_tile() +
facet_wrap(vars(site), ncol = 1) +
...
ggplot(barley, aes(yield, variety,
color = year)) +
geom_point(...) +
facet_wrap(vars(site), ncol = 1) +
...
ggplot(barley, aes(year, yield,
group = variety,
color = variety)) +
geom_line() +
facet_wrap(vars(site), nrow = 1) +
...
ggplot(barley, aes(x = year, y = yield,
group = site,
color = site)) +
stat_summary(fun = mean,
geom = "line", ...) +
stat_summary(fun.data = mean_sdl,
geom = "errorbar", ...) +
...
ggplot(barley, aes(x = year, y = yield,
group = site,
color = site)) +
stat_summary(fun = mean,
geom = "line", ...) +
stat_summary(fun.data = mean_sdl,
geom = "ribbon", ...) +
...
Intermediate Data Visualization with ggplot2