Intro to R
  • Home
  • Syllabus
  • Lectures
  • Homework
  • Software Setup

On this page

  • Info and Materials
  • Learning Objectives
  • Before Class
  • Readings

Lecture 3: Intro to ggplot2, Coding Style

Published

July 1, 2025

Info and Materials

  • Date: July 1, 2025
  • Topics: Visualizing Data with ggplot2, Coding Style in R
  • Slides: View Slides
  • Code: usethis::use_course("csp-materials/ggplot2-style")

Learning Objectives

  • Recognize the role of visualization in exploring and communicating data
  • Understand the basic principles of the “Layered Grammar of Graphics”
  • Create simple layered plots using ggplot2
  • Apply correct coding style practices when writing R code

Before Class

  • Review the Lecture 2 materials to get ready for today’s in-class quiz
  • Start Homework 1. Have questions or need help? Join us for Office Hours right after class!
  • Bring your laptop to every class

Readings

Skim the readings before or after class to get the big picture and prep for quizzes and assignments:

  • Chapter 4 “Workflow: Code Style” from “R for Data Science” 2nd Edition
  • Chapter 1 “Data Visualization” from “R for Data Science” 2nd Edition

Additional Resources (not needed for quizzes or homework, but helpful to dive deeper):

  • ggplot2 Cheat Sheet
  • ggplot2 Official Documentation
  • ggplot2: Elegant Graphics for Data Analysis, 2nd Edition by Hadley Wickham. Excellent resource for learning the intricacies of ggplot2
  • R Graphics Cookbook, 2nd edition by Winston Chang. A practical guide with 150 examples to generate quality graphics based on the data you wish to present
  • “The tidyverse style guide”