# 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.29 |
2155.49 |
215.62 |
4.33 |
7.37 |
InPlay |
6.01 |
1.90 |
5.20 |
7.2 |
Sinker |
87.98 |
2092.96 |
229.48 |
15.92 |
14.90 |
BallCalled |
6.29 |
1.56 |
5.29 |
7.6 |
Sinker |
87.28 |
2140.41 |
224.76 |
15.89 |
17.42 |
BallCalled |
6.28 |
1.57 |
5.34 |
7.5 |
Slider |
83.33 |
2325.85 |
186.42 |
0.83 |
8.62 |
StrikeCalled |
6.02 |
1.84 |
5.01 |
6.2 |
Slider |
82.76 |
2244.30 |
222.08 |
5.45 |
7.39 |
BallCalled |
5.93 |
1.81 |
5.49 |
7.4 |
Changeup |
84.79 |
1888.79 |
232.30 |
16.88 |
14.42 |
FoulBallNotFieldable |
6.06 |
1.97 |
5.08 |
7.7 |
Slider |
78.15 |
2408.43 |
83.47 |
-7.11 |
0.54 |
BallCalled |
5.86 |
1.89 |
5.09 |
2.8 |
Sinker |
86.50 |
2046.31 |
230.20 |
16.82 |
15.35 |
BallCalled |
6.06 |
1.80 |
5.52 |
7.7 |
Changeup |
84.89 |
1816.20 |
249.58 |
18.79 |
8.32 |
StrikeSwinging |
5.93 |
1.96 |
5.16 |
8.3 |
Changeup |
80.54 |
1944.17 |
253.71 |
17.42 |
6.54 |
BallCalled |
5.80 |
1.93 |
5.56 |
8.5 |
Slider |
82.64 |
2173.17 |
188.96 |
0.80 |
6.28 |
StrikeCalled |
5.78 |
2.02 |
5.21 |
6.3 |
Sinker |
87.84 |
2110.53 |
229.55 |
17.90 |
16.57 |
StrikeSwinging |
6.01 |
1.85 |
5.23 |
7.7 |
Changeup |
85.08 |
1826.95 |
257.05 |
20.72 |
6.09 |
StrikeCalled |
5.89 |
2.00 |
4.94 |
8.6 |
Sinker |
88.23 |
2134.65 |
225.97 |
18.20 |
18.92 |
InPlay |
6.11 |
1.70 |
5.29 |
7.5 |
# 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: 14
# Display the summary table
knitr::kable(pitch_summary, caption = "Summary Pitch Table for Derek Benzinger")
Summary Pitch Table for Derek Benzinger
Changeup |
28.57% |
4 |
1 |
3 |
25.00% |
75.00% |
83.83 |
1869.03 |
8.84 |
18.45 |
248.16 |
8.3 |
5.92 |
1.96 |
5.19 |
Sinker |
35.71% |
5 |
3 |
2 |
60.00% |
40.00% |
87.57 |
2104.97 |
16.63 |
16.95 |
227.99 |
7.6 |
6.15 |
1.70 |
5.33 |
Slider |
35.71% |
5 |
2 |
3 |
40.00% |
60.00% |
81.83 |
2261.45 |
6.04 |
0.86 |
179.31 |
6.0 |
5.92 |
1.89 |
5.20 |
# 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: 88.23 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, 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")
)
