Day 3: Introduction to Data Visualization with the ggplot2 package
If you want to visualize your data, the R package ggplo2 does everything you need. The ggplot2 package has many functions that let you customize your plots exactly how you want. This lecture is not a comprehensive guide to all of them, but it will equip you with the basic skills to create the most common types of figures. The skills you will learn in this lecture will apply to more advanced plot-making. Let’s get started!
Learning Objectives
- Learn the basic sysntax of
geom_*function of theggplot2package to create figures. - To be able to create:
- scatter plot
- line plot
- bar plot
- histogram
- box plot
- density plot
- facet plot
- To be able to transform the data to make it suitable for visualization with ggplot functions.
Preparation
Before the class, see what kind of figures you can create with the
ggplot2package from the official website.Here is a brief overview of the key components used in the ggplot2 package. Specifically, if you understand that any complicated plot is composed of multiple simple plot layers, then it is easy to understand how to create a plot with ggplot2!
Lecture Slides
Click here for Lecture 3’s slides.
Exercise problems: Exercise problems for Lecture 3. Solution is attached.
Quick view of the lecture slides:
Supplementary Materials
ggplot2homepage: ggplot2