Data visualization with ggplot2

Masumbuko Semba
Nyamisi Peter

2024-04-01

Learning Agenda

  1. Get familiar with R and Rstudio
  2. Data structure and data types
  3. Reading and writing data in Rstudio
  4. Tidying with tidyverse
  5. Plotting and Visualization
  6. Data manipulation with tidyverse
  7. Descriptive Statistics
  8. Inferential Statistics
  9. Modelling and simulation
  10. Spatial Handling and Analysis

OVERVIEW

Questions

  1. How do you make plots using R?
  2. How do you customize and modify plots?

Objectives

  1. Produce histogram, scatter plots, boxplots, line plots and barplots using ggplot
  2. Describe what faceting is and apply faceting in ggplot
  3. Modify the aesthetics of an existing ggplot plot .

Plotting with ggplot2

  • ggplot2 create complex plots from data in a data frame.

  • ggplot2 plots work best with data in the ‘long’ format

  • To build a ggplot, we will use the following basic template that can be used for different types of plots:

\[ Plot = Data + Aesthetics + Geom \]