Udemy
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
Pitch Location Charts with PITCHf/x and ggplot
Rating: 4.8 out of 5(107 ratings)
6,134 students

Pitch Location Charts with PITCHf/x and ggplot

Visually analyze each at-bat of a baseball game.
Created byCharles Redmond
Last updated 7/2015
English

What you'll 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

Course content

6 sections37 lectures2h 11m total length
  • Introduction1:01

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

  • PITCHf/x Data4:14

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

  • Scraping the Data4:50

    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.

  • Joining the atbat and pitch Data Frames4:46

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

  • Choosing Columns from the atbat Data Frame4:39

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

  • Choosing Columns from the pitch Data Frame2:31

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

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 this course is for:

  • 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.