Load the package. It assumes that the packages ggplot2, dplyr, baseballr, and mgcv have already been installed.

library(CalledStrike)

Collect Data

Here we find the MLBAM id for Mike Trout. The get_sc_data() function (wrapper for the baseballr function) will download the Statcast data for Trout for the 2018 season.

mt_id <- get_id("Mike Trout")
mt <- get_sc_data(mt_id, season = 2018)

Called Strikes

This constructs a tile plot for the probability that a called pitch is a strike.

called_strike_plot(mt, "Mike Trout Called Strikes")

Miss Swing Rates

Constructs a tile plot for the probability that Trout misses on a swing.

miss_swing_plot(mt, "Mike Trout Miss Swing Rates")

Zones of Hits and Home Runs

Constructs a tile plot for the probability that Trout hits a home run on a ball in-play.

home_run_plot(mt, "Mike Trout Home Run Rates")

Constructs a tile plot for the probability that Trout gets a hit on a ball in-play.

hit_plot(mt, "Mike Trout Hit Rates")

Statcast Variables (launch speed, launch angle, spray angle)

Constructs a tile plot for the launch speed on a ball in-play.

ls_plot(mt, "Mike Trout Launch Speeds")