Pitch Location Charts with PITCHf/x and ggplot
4.9 (30 ratings)
Instead of using a simple lifetime average, Udemy calculates a course's star rating by considering a number of different factors such as the number of ratings, the age of ratings, and the likelihood of fraudulent ratings.
2,648 students enrolled
Wishlisted Wishlist

Please confirm that you want to add Pitch Location Charts with PITCHf/x and ggplot to your Wishlist.

Add to Wishlist

Pitch Location Charts with PITCHf/x and ggplot

Visually analyze each at-bat of a baseball game.
4.9 (30 ratings)
Instead of using a simple lifetime average, Udemy calculates a course's star rating by considering a number of different factors such as the number of ratings, the age of ratings, and the likelihood of fraudulent ratings.
2,648 students enrolled
Last updated 7/2015
English
Price: Free
Includes:
  • 2 hours on-demand video
  • Full lifetime access
  • Access on mobile and TV
  • Certificate of Completion
What Will I Learn?
scrape PITCHf/x data into an R session
plot pitch locations with ggplot
visualize pitch type and speed with ggplot
subset vectors in R
work with color in ggplot
facet in ggplot
label with geom_text
work with seq, lapply, unlist, and unique in R
save plots as png's
write for loops in R
work with factors in R
View Curriculum
Requirements
  • Students will need to have R and RStudio installed on their own computers.
Description

In this course, we make use of PITCHf/x data to create pitch location charts for a given baseball game. We break the game out into each at-bat and visualize the location, type, and speed of each pitch, the order in which the pitches were thrown, and the outcome of the at-bat.

In order to accomplish this, we will be taking a deep dive into ggplot. We will learn much about how to work with color, how to use aesthetics, and how to facet. We will also gain additional R skills, such as how to subset a vector and how to work with factors.

One should be able to complete the course, at a relaxed pace, in about three weeks. It is best if students already have a little bit of a background in R, dplyr, and ggplot, but it is not completely necessary.

Who is the target audience?
  • This course is for students interested in learning how to create pitch location charts and how to wrangle data from PITCHf/x.
  • It would be best for each student to have a bit of a background in R, dplyr, and ggplot, but it is not completely necessary.
Students Who Viewed This Course Also Viewed
Curriculum For This Course
Expand All 37 Lectures Collapse All 37 Lectures 02:11:22
+
Extracting PITCHf/x Data
6 Lectures 22:01

In this video, I state the goals of the course.

Introduction
01:01

After viewing this lecture, you will know where to access PITCHf/x data and understand a bit about its structure.

PITCHf/x Data
04:14

After viewing this lecture, you will be able to scrape the data for a single game from the PITCHf/x website and access the data frames in which the data is stored.

Scraping the Data
04:50

After viewing this lecture, you will be able to join the atbat and pitch data frames.

Joining the atbat and pitch Data Frames
04:46

In this lecture, we select what we need from the atbat data frame.

Choosing Columns from the atbat Data Frame
04:39

In this lecture, we select what we need from the pitch data frame.

Choosing Columns from the pitch Data Frame
02:31
+
Multi-Batter Visualizations
7 Lectures 24:43

In this lecture, I give the coordinates of the strike-zone.

The Strike-Zone
01:50

After viewing this lecture, you will be able to work with geom_path to draw a strike-zone with ggplot.

Drawing the Strike-Zone
04:24

After viewing this lecture, you will be able to plot all of the pitches thrown by Max Scherzer as points.

Vizualizing the Pitch Locations
02:26

After viewing this lecture, you will be able to use the ggplot size parameter within the aesthetics to visualize the speed of each pitch.

Visualizing Pitch Speed
03:42

After viewing this lecture, you will be able to use the ggplot color parameter within the aesthetics to visualize the type of each pitch.

Visualizing Pitch Type
03:17

After viewing this lecture, you will be able to subset vectors and use the "which" function in R.

Subsetting R vectors and "which"
04:27

After viewing this lecture, you will be able to use the "which" function to generate a more descriptive pitch type column.

Better Pitch Descriptions
04:37
+
Working with Color
6 Lectures 16:53

After viewing this lecture, you will be able to set the hue of points in ggplot.

Hue
03:59

After viewing this lecture, you will be able to set the chromaticity, or saturation, of points in ggplot.

Chromaticity (saturation)
01:49

After viewing this lecture, you will be able to set the luminance, or brightness, of points in ggplot.

Luminance (brightness)
01:08

After viewing this lecture, you will be able to use the RColorBrewer package to pick a color palette for displaying points in ggplot.

Palettes
01:51

After viewing this lecture, you will be able to manually specify your own color palette for displaying points in ggplot.

Manual Color Specification
03:04

After viewing this lecture, you will understand factors and you will be able to work with them.

Colors and Factors
05:02
+
Faceting
4 Lectures 16:22

After viewing this lecture, you will be able to facet in ggplot, and you will also be able to work with geom_text.

Faceting with One Variable
05:06

In this lecture, we do more problem solving with the "which" function.

Stand on the Correct Side
04:10

In this lecture, we do more problem solving with factors.

Facet Order through Factors
01:32

In this lecture, we do more problem solving with faceting and geom_text.

Faceting by At-Bat
05:34
+
At-Bat by At-Bat
7 Lectures 25:38

In this lecture, we separate out a single at-bat for visualization. We also learn how to work with the paste function and how to set limits for the axes.

Specifying Batter and Inning
05:41

In this lecture, we do more problem solving with geom_text, and we learn about the vjust parameter.

Labeling Pitches
04:30

In this lecture, we do more problem solving with the "which" function.

Replacing "In Play"
05:27

In this lecture, we review grouping and counting with dplyr.

Counting the Number of Pitches in an At-Bat
03:47

After viewing this lecture, you will be able to use the seq and lapply functions in R.

lapply and seq
02:01

After viewing this lecture, you will be able to work with the unlist function.

unlist
01:49

In this lecture, we finally enumerate the pitches within each at-bat.

Visualizing Pitch Enumeration
02:23
+
Slide-Show
7 Lectures 25:45

After viewing this lecture, you will be able to save a plot from ggplot to a png.

Saving a Single Plot
02:36

In this lecture, we learn how to write a for loop. We also learn how to work with the unique function.

For Loop Part I
03:38

In this lecture, we make the necessary changes to our code withing the for loop.

For Loop Part II
03:41

In this lecture, we discover two additional problems we must solve before our final product is satisfactory.

Difficulties and Problems!
02:41

In this lecture, we learn how to work with the names function to solve our color problem.

Solving the Color Problem
04:12

In this lecture, I discuss the mappings of intervals to intervals, a technique that will help us solve our speed problem.

Solving the Speed Problem Part I
04:59

In this lecture, we implement the solution described in the last lecture and wrap-up the course.

Solving the Speed Problem Part II and Wrap-Up
03:58
About the Instructor
Charles Redmond
4.6 Average rating
1,416 Reviews
19,273 Students
7 Courses
Professor at Mercyhurst University

Dr. Charles Redmond is a professor in the Tom Ridge School of Intelligence Studies and Information Science at Mercyhurst University. He has been a member of the Department of Mathematics and Computer Systems at Mercyhurst for 21 years and has recently completed a term as chair of the department. Dr. Redmond received his PhD in mathematics from Lehigh University in 1993 and has published in the Annals of Applied Probability, the Journal of Stochastic Processes and Their Applications, Mathematics Magazine, the College Mathematics Journal, and Mathematics Teacher. In his spare time he enjoys making music and computer generated art, reading, and owning a Clumber Spaniel.