# 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
Slider |
82.49 |
2341.65 |
166.28 |
-1.77 |
8.43 |
FoulBallNotFieldable |
5.84 |
1.83 |
4.84 |
5.5 |
Slider |
78.25 |
2542.76 |
94.10 |
-13.48 |
2.55 |
FoulBallNotFieldable |
5.84 |
1.81 |
4.55 |
3.1 |
Sinker |
88.60 |
2036.79 |
224.69 |
16.02 |
17.48 |
FoulBallNotFieldable |
6.01 |
1.90 |
5.28 |
7.5 |
Changeup |
81.86 |
2052.19 |
259.18 |
18.17 |
4.93 |
BallCalled |
5.56 |
1.92 |
5.53 |
8.6 |
Slider |
83.79 |
2392.00 |
160.05 |
-1.91 |
6.60 |
InPlay |
5.89 |
1.65 |
4.95 |
5.3 |
Slider |
76.95 |
2323.33 |
84.00 |
-7.24 |
0.79 |
StrikeSwinging |
5.81 |
1.95 |
4.88 |
2.8 |
Slider |
78.82 |
2491.24 |
96.20 |
-8.98 |
2.48 |
BallCalled |
5.81 |
1.94 |
4.90 |
3.2 |
Slider |
83.37 |
2393.30 |
157.76 |
-2.78 |
8.19 |
FoulBallNotFieldable |
5.84 |
1.99 |
4.42 |
5.3 |
Four-Seam |
88.22 |
2176.42 |
216.82 |
11.15 |
16.27 |
BallCalled |
6.12 |
1.82 |
4.79 |
7.2 |
Slider |
78.85 |
2622.91 |
109.93 |
-7.98 |
4.34 |
BallCalled |
5.78 |
1.83 |
4.97 |
3.7 |
Slider |
82.51 |
2385.99 |
145.26 |
-3.07 |
5.90 |
FoulBallNotFieldable |
5.80 |
1.83 |
4.81 |
4.8 |
Sinker |
88.49 |
2029.77 |
239.20 |
15.63 |
10.50 |
BallCalled |
6.06 |
1.87 |
5.04 |
8.0 |
Slider |
83.62 |
2380.57 |
172.12 |
-1.16 |
9.63 |
BallCalled |
5.86 |
1.84 |
4.92 |
5.7 |
Sinker |
88.69 |
2072.13 |
245.37 |
15.88 |
8.48 |
FoulBallNotFieldable |
6.00 |
1.85 |
5.02 |
8.2 |
Curveball |
78.07 |
2571.25 |
70.35 |
-8.28 |
-1.52 |
BallCalled |
5.87 |
1.77 |
4.79 |
2.3 |
Slider |
83.02 |
2392.23 |
150.24 |
-3.97 |
8.12 |
HitByPitch |
6.06 |
1.67 |
4.80 |
5.0 |
Slider |
83.31 |
2306.89 |
155.13 |
-2.93 |
7.73 |
StrikeCalled |
5.98 |
1.78 |
4.87 |
5.2 |
Slider |
83.42 |
2340.23 |
116.21 |
-6.41 |
4.45 |
StrikeSwinging |
5.99 |
1.58 |
4.73 |
3.9 |
Slider |
84.62 |
2441.95 |
160.51 |
-2.22 |
7.52 |
BallCalled |
6.07 |
1.53 |
4.80 |
5.4 |
Slider |
82.94 |
2454.66 |
148.03 |
-2.99 |
6.15 |
InPlay |
5.99 |
1.68 |
4.89 |
4.9 |
# 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 == "BallCalled"),
Strikes = sum(PitchCall != "BallCalled"), # 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 |
5.00% |
1 |
1 |
0 |
100.00% |
0.00% |
81.86 |
2052.19 |
4.93 |
18.17 |
259.18 |
8.6 |
5.56 |
1.92 |
5.53 |
Curveball |
5.00% |
1 |
1 |
0 |
100.00% |
0.00% |
78.07 |
2571.25 |
-1.52 |
-8.28 |
70.35 |
2.3 |
5.87 |
1.77 |
4.79 |
Four-Seam |
5.00% |
1 |
1 |
0 |
100.00% |
0.00% |
88.22 |
2176.42 |
16.27 |
11.15 |
216.82 |
7.2 |
6.12 |
1.82 |
4.79 |
Sinker |
15.00% |
3 |
1 |
2 |
33.33% |
66.67% |
88.59 |
2046.23 |
12.15 |
15.84 |
236.42 |
7.9 |
6.02 |
1.87 |
5.11 |
Slider |
70.00% |
14 |
4 |
10 |
28.57% |
71.43% |
81.85 |
2414.98 |
5.92 |
-4.78 |
136.84 |
4.6 |
5.90 |
1.78 |
4.81 |
# Calculate maximum fastball velocity
max_fb_velocity <- detailed_pitch_table %>%
filter(AutoPitchType %in% c("Four-Seam", "Two-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: 88.69 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", "FoulBallNonSwinging", "FoulBallFieldable", "FoulBallNotFieldable", "InPlay"), "Swing", "Take"),
Chase = ifelse(SwingTake == "Swing" & (PitchSide < -0.75 | PitchSide > 0.75 | 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.75, xmax = 0.75, 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, 25)) + # 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")
)
