Tidy data and ggplot2
Outline
Tidying data for ggplot
- ggplot uses data in tidy format
- In tidy data, each row is one observations
- Columns are characteristics of that observation
- Tidy data manifesto https://cran.r-project.org/web/packages/tidyr/vignettes/tidy-data.html
- Most datasets do not arrive in a tidy form, so they must be tidied
Intro to ggplot
- ggplot is a graphical grammar for making plots
- It has a common syntax for many different types of plots (geoms)
- http://docs.ggplot2.org/current/
An example analysis
- Calculating a statistic and visualizing the results
Choosing the right geom
- The right choice usually not a bar plot
- http://thenode.biologists.com/barbarplots/photo/
Making aesthetically pleasing plots
- ggplot default plots need a bit of work before publishing
- Change colors, line thickness, labels, plot elements, etc.