library(pitcheR) knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
<<<<<<< HEAD
=======
Break Summary Function:
The break summary function, coded as "break_func()" returns a plot of the average break for each pitch type that the given pitcher has. Similar to all functions in the package, the only input the function requires is the standard csv statcast data file. The x-axis is the average horizontal break for the respective pitch, in feet. A negative value would indicate a break to the left, and positive value would indicate a break to the right. The y-axis is the average vertical break for the respective pitch, also measured in feet. A positive value indicates an upward break, and a negative value indicates a downward break. Each line represents a different pitch type, the plot is also colored by pitch type.
break_summary <- break_func(file = deGrom) break_summary
The above plot is the result of using the "break_func" function with the data file for DeGrom, as seen in the code above. This plot shows that DeGrom has 4 different pitch types (a link to the description of the pitch types can be found .....* ). His fastball (pitch type FF) has the largest average break, which breaks upwards and to the left. We can also see that all of his pitches break, on average, by different amounts and in different directions, as no two pitches follow the same line.
The idea with this function is to provide the user with a simple summary of pitch location from their csv file.
location_example <- location_heatmap(file = deGrom, by_pitch_type = TRUE) location_example
In this case, we are looking at Jacob deGrom's pitches from 2021 and where he threw them. From this graphic we are able to discern a few things quickly. First, his pitch usage varies by pitch type, and that his pitch location varies by pitch type. We notice that curve balls (CU) are his least used pitch. We can also quickly see that he favors a fastball (FF) up in the zone, and a slider(SL) low and out of the zone. It is useful to be able to quickly discern this information from one graphic.
Very similar to location heatmap, this function is used to provide the user with a summary of pitches thrown that were put into play.
example1 <- contact_location_heatmap(file = deGrom, by_pitch_type = TRUE, hit.status = FALSE, min.exit.velocity =0.0) example1 example2 <- contact_location_heatmap(file = deGrom, by_pitch_type = TRUE, hit.status = FALSE, min.exit.velocity =90.0) example2
Again, we take a look at deGrom's 2021 season. This time, the first graphic shows us where the pitches he throws get put into play. Again there are sparse data points for the Change up (CH) and Curve, but relevant information for the slider and fastball. The fastball appears to mirror his location heat map, but his sliders appear mostly to be put into play if they are in the zone. This strays a little from his location heatmap.
The second graphic shows balls put into play that were hit at least 90 mph. Here we can see that the slider is very rarely put into play with a hard contact when it is thrown outside of the zone. This can help us infer why deGrom may throw his slider out of the zone on his location heatmap.
Custom heatmap provides a very similar service to location heatmap. The main difference is its utility in terms of baseball interpretations. Specifically, the zone is always split into a 3x3 grid, which is a common practice in the baseball pitching world. Thus, it is useful for smaller data sets, or subsetted data sets.
library(dplyr) deGrom_FF_game_1 <- deGrom %>% filter(game_date == "2021-04-05",pitch_type=="FF") custom_heatmap(file = deGrom_FF_game_1)
Now this graph shows us where deGrom threw his fastballs in his first appearance of the 2021 season. We are now using a much smaller dataset, however this can help provide insight on a game to game basis. In his first start, he favored throwing fastballs primarily at the top or above the zone.
One of the more important metrics for a pitcher is the percentage of pitches missed by a better in which he swings. This function takes a statcast data file and calculates the swinging strike percentage for each pitch type for a given pitcher. The ouput is a table which contains this percentage for each pitch, as well as the respective speed and spin rate for said pitch type.
swg_strike(deGrom)
This table pairs well with the break summary function as it tells us which pitches for a given pitcher are being swung at and missed the most. We can use this table and the graphics from break summary to infer what type of pitch movement induces the highest percentage of swings and misses.
The function "velo_bp" overlays density plots showing the density of pitch release speed, by the type of pitch. Similar to many of the other functions in this package, the only input needed is a 'statcast' data file. The x-axis is release speed, in mph, and the y-axis is density.
velo_bp(file = deGrom)
Above, we can see the release speed of a pitch by pitch type for DeGrom's 2021 season.
One of the growing interests in today's game is velocity of a pitch, specifically fastballs. This function works very well in conjunction with the velo_bp function. The output of this function is a graph of a pitcher's average velocity for a given pitch type on a per game basis.
velo_time(deGrom)
This graph can tell us if a pitcher is consistent with his pitch velocity, or if perhaps he loses velocity per game over the course of the season.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.