# Filter the data for the pitcher Derek Benzinger
Brian_Foley_data <- data %>%
filter(Pitcher == "Benzinger, Derek")
# Create a detailed table for each pitch
detailed_pitch_table <- Brian_Foley_data %>%
select(AutoPitchType, RelSpeed, SpinRate, SpinAxis, HorzBreak, InducedVertBreak, PitchCall, RelHeight, RelSide, Extension) %>%
rename(
ReleaseSpeed = RelSpeed,
Tilt = SpinAxis,
HorizontalBreak = HorzBreak,
InducedVerticalBreak = InducedVertBreak,
ReleaseHeight = RelHeight,
ReleaseSide = RelSide
) %>%
mutate(
ReleaseSpeed = round(ReleaseSpeed, 2),
SpinRate = round(SpinRate, 2),
Tilt = round(Tilt, 2),
HorizontalBreak = round(HorizontalBreak, 2),
InducedVerticalBreak = round(InducedVerticalBreak, 2),
ReleaseHeight = round(ReleaseHeight, 2),
ReleaseSide = round(ReleaseSide, 2),
Extension = round(Extension, 2),
ClockTilt = round((Tilt / 30) %% 12, 1) # Interpret Tilt as clock face
)
# Display the detailed table
knitr::kable(detailed_pitch_table, caption = "Detailed Pitch Table for Derek Benzinger")
Detailed Pitch Table for Derek Benzinger
Four-Seam |
86.65 |
2088.94 |
215.33 |
15.86 |
24.06 |
InPlay |
6.40 |
1.17 |
5.48 |
7.2 |
Four-Seam |
86.74 |
2118.92 |
209.11 |
12.11 |
23.24 |
BallCalled |
6.30 |
1.64 |
5.51 |
7.0 |
Changeup |
86.35 |
2005.48 |
216.49 |
12.53 |
18.32 |
BallCalled |
6.03 |
1.65 |
5.30 |
7.2 |
Changeup |
85.06 |
1897.61 |
271.51 |
15.26 |
0.91 |
StrikeCalled |
6.09 |
1.54 |
5.61 |
9.1 |
Changeup |
86.58 |
1980.22 |
227.41 |
14.93 |
15.16 |
BallCalled |
6.09 |
1.61 |
5.52 |
7.6 |
Four-Seam |
86.37 |
2179.27 |
199.46 |
7.34 |
22.15 |
StrikeCalled |
6.27 |
1.52 |
5.37 |
6.6 |
Four-Seam |
87.90 |
2149.08 |
212.63 |
12.19 |
20.39 |
BallCalled |
6.27 |
1.45 |
5.58 |
7.1 |
Slider |
82.02 |
2380.96 |
177.75 |
-0.39 |
11.31 |
BallCalled |
6.15 |
1.63 |
5.31 |
5.9 |
Four-Seam |
87.43 |
2209.39 |
204.75 |
9.19 |
21.28 |
BallCalled |
6.19 |
1.17 |
5.58 |
6.8 |
Slider |
77.05 |
2584.11 |
104.57 |
-9.47 |
3.96 |
BallCalled |
6.10 |
1.46 |
5.39 |
3.5 |
Four-Seam |
87.50 |
2194.48 |
201.24 |
8.00 |
22.00 |
InPlay |
6.27 |
1.35 |
5.53 |
6.7 |
Changeup |
87.70 |
1982.39 |
249.01 |
16.73 |
7.60 |
BallCalled |
6.00 |
1.64 |
5.52 |
8.3 |
Changeup |
87.59 |
1981.66 |
254.56 |
16.85 |
5.83 |
StrikeSwinging |
6.11 |
1.51 |
5.66 |
8.5 |
Changeup |
86.66 |
1970.42 |
250.88 |
16.00 |
6.84 |
StrikeSwinging |
6.11 |
1.52 |
5.59 |
8.4 |
Changeup |
83.04 |
2035.96 |
251.34 |
16.92 |
7.24 |
StrikeSwinging |
5.81 |
1.69 |
6.03 |
8.4 |
Slider |
86.06 |
2456.77 |
186.72 |
1.31 |
12.43 |
InPlay |
6.06 |
1.56 |
5.46 |
6.2 |
Sinker |
86.61 |
1918.75 |
221.09 |
9.51 |
12.03 |
StrikeCalled |
5.18 |
2.04 |
6.44 |
7.4 |
Curveball |
76.05 |
2103.13 |
69.52 |
-15.28 |
-4.25 |
BallCalled |
5.06 |
2.16 |
5.94 |
2.3 |
Changeup |
85.98 |
1932.27 |
246.41 |
19.69 |
9.89 |
BallCalled |
5.21 |
1.81 |
6.43 |
8.2 |
Sinker |
87.13 |
2046.01 |
233.19 |
14.71 |
12.15 |
StrikeCalled |
5.27 |
1.86 |
6.51 |
7.8 |
# Calculate the total number of pitches
total_pitches <- nrow(detailed_pitch_table)
# Create a summary table
pitch_summary <- detailed_pitch_table %>%
group_by(AutoPitchType) %>%
summarise(
TotalPitches = n(),
Usage = sprintf("%.2f%%", n() / total_pitches * 100),
Balls = sum(PitchCall %in% c("BallCalled", "BallinDirt")),
Strikes = sum(!PitchCall %in% c("BallCalled", "BallinDirt")), # Count everything not a ball as a strike
BallPercentage = sprintf('%.2f%%', Balls / TotalPitches * 100),
StrikePercentage = sprintf('%.2f%%', Strikes / TotalPitches * 100),
AvgVelocity = round(mean(ReleaseSpeed, na.rm = TRUE), 2),
AvgSpinRate = round(mean(SpinRate, na.rm = TRUE), 2),
AvgInducedVertBreak = round(mean(InducedVerticalBreak, na.rm = TRUE), 2),
AvgHorzBreak = round(mean(HorizontalBreak, na.rm = TRUE), 2),
AvgTilt = round(mean(Tilt, na.rm = TRUE), 2),
AvgClockTilt = round(mean(ClockTilt, na.rm = TRUE), 1), # Clock face interpretation
AvgReleaseHeight = round(mean(ReleaseHeight, na.rm = TRUE), 2),
AvgReleaseSide = round(mean(ReleaseSide, na.rm = TRUE), 2),
AvgExtension = round(mean(Extension, na.rm = TRUE), 2)
) %>%
select(AutoPitchType, Usage, everything())
# Display the total number of pitches
cat("Total number of pitches thrown: ", total_pitches, "\n")
## Total number of pitches thrown: 20
# Display the summary table
knitr::kable(pitch_summary, caption = "Summary Pitch Table for Derek Benzinger")
Summary Pitch Table for Derek Benzinger
Changeup |
40.00% |
8 |
4 |
4 |
50.00% |
50.00% |
86.12 |
1973.25 |
8.97 |
16.11 |
245.95 |
8.2 |
5.93 |
1.62 |
5.71 |
Curveball |
5.00% |
1 |
1 |
0 |
100.00% |
0.00% |
76.05 |
2103.13 |
-4.25 |
-15.28 |
69.52 |
2.3 |
5.06 |
2.16 |
5.94 |
Four-Seam |
30.00% |
6 |
3 |
3 |
50.00% |
50.00% |
87.10 |
2156.68 |
22.19 |
10.78 |
207.09 |
6.9 |
6.28 |
1.38 |
5.51 |
Sinker |
10.00% |
2 |
0 |
2 |
0.00% |
100.00% |
86.87 |
1982.38 |
12.09 |
12.11 |
227.14 |
7.6 |
5.22 |
1.95 |
6.47 |
Slider |
15.00% |
3 |
2 |
1 |
66.67% |
33.33% |
81.71 |
2473.95 |
9.23 |
-2.85 |
156.35 |
5.2 |
6.10 |
1.55 |
5.39 |
# Calculate maximum fastball velocity
max_fb_velocity <- detailed_pitch_table %>%
filter(AutoPitchType %in% c("Four-Seam", "Sinker", "Cutter")) %>%
summarise(MaxFBVelocity = max(ReleaseSpeed, na.rm = TRUE)) %>%
pull(MaxFBVelocity)
# Display the maximum fastball velocity
cat("Derek Benzinger maximum FB velocity: ", max_fb_velocity, "mph\n")
## Derek Benzinger maximum FB velocity: 87.9 mph
# Prepare data for plotting pitch locations
pitch_location_data <- Brian_Foley_data %>%
select(AutoPitchType, PlateLocHeight, PlateLocSide, PitchCall) %>%
rename(
PitchHeight = PlateLocHeight,
PitchSide = PlateLocSide
) %>%
mutate(
SwingTake = ifelse(PitchCall %in% c("StrikeSwinging", "FoulBall", "FoulBallFieldable", "FoulBallNotFieldable", "InPlay"), "Swing", "Take"),
Chase = ifelse(SwingTake == "Swing" & (PitchSide < -0.85 | PitchSide > 0.85 | PitchHeight < 1.5 | PitchHeight > 3.5), "Chase", "Non-Chase")
)
# Create the scatter plot with specified strike zone boxes
ggplot(pitch_location_data, aes(x = PitchSide, y = PitchHeight, color = SwingTake, shape = Chase)) +
geom_point(size = 3) +
geom_rect(aes(xmin = -0.5, xmax = 0.5, ymin = 1.75, ymax = 3.25), fill = NA, color = "red", linetype = "solid", size = 1) +
geom_rect(aes(xmin = -0.85, xmax = 0.85, ymin = 1.5, ymax = 3.5), fill = NA, color = "black", linetype = "solid", size = 1) +
geom_rect(aes(xmin = -1.25, xmax = 1.25, ymin = 1.25, ymax = 3.75), fill = NA, color = "gray", linetype = "solid", size = 1) +
scale_x_continuous(limits = c(-2, 2)) +
scale_y_continuous(limits = c(0, 5)) +
coord_fixed(ratio = 1) +
labs(title = "Pitch Locations for Derek Benzinger",
x = "Horizontal Location (feet)",
y = "Vertical Location (feet)",
color = "Swing/Take",
shape = "Chase") +
facet_wrap(~ AutoPitchType) +
theme_minimal() +
theme(
legend.position = "right",
panel.grid.major = element_line(color = "grey80"),
panel.grid.minor = element_line(color = "grey90"),
axis.text = element_text(color = "black"),
axis.title = element_text(color = "black"),
plot.title = element_text(color = "black"),
legend.background = element_rect(fill = "white", color = NA),
legend.key = element_rect(fill = "white", color = NA),
legend.text = element_text(color = "black"),
legend.title = element_text(color = "black")
)

# Create the scatter plot for horizontal and vertical breaks
ggplot(detailed_pitch_table, aes(x = HorizontalBreak, y = InducedVerticalBreak, color = AutoPitchType)) +
geom_point(size = 3) + # Increase point size
scale_x_continuous(limits = c(-25, 25)) + # Set horizontal limits to +/- 25 inches
scale_y_continuous(limits = c(-25, 26)) + # Set vertical limits to +/- 25 inches
labs(title = paste("Pitch Movement"),
x = "Horizontal Break (inches)",
y = "Induced Vertical Break (inches)",
color = "Pitch Type") +
theme_minimal() +
theme(
legend.position = "right",
panel.grid.major = element_line(color = "grey80"),
panel.grid.minor = element_line(color = "grey90"),
axis.text = element_text(color = "black"),
axis.title = element_text(color = "black"),
plot.title = element_text(color = "black"),
legend.background = element_rect(fill = "white", color = NA),
legend.key = element_rect(fill = "white", color = NA),
legend.text = element_text(color = "black"),
legend.title = element_text(color = "black")
)
