# Filter the data for the pitcher Aidan Krupp
Aidan_Krupp_data <- Upper630G1 %>%
filter(Pitcher == "Krupp, Aidan")
# Create a detailed table for each pitch
detailed_pitch_table <- Aidan_Krupp_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 Aidan Krupp")
Detailed Pitch Table for Aidan Krupp
Changeup |
84.60 |
2025.75 |
266.86 |
19.82 |
2.63 |
BallCalled |
4.38 |
2.62 |
5.98 |
8.9 |
Changeup |
86.68 |
2094.98 |
260.40 |
22.85 |
5.38 |
StrikeCalled |
4.51 |
2.55 |
5.97 |
8.7 |
Changeup |
84.76 |
2080.58 |
262.04 |
20.01 |
4.34 |
BallCalled |
4.50 |
2.46 |
6.07 |
8.7 |
Changeup |
83.99 |
2119.57 |
242.24 |
16.31 |
10.15 |
BallCalled |
4.19 |
2.59 |
6.07 |
8.1 |
Changeup |
85.65 |
2077.58 |
265.43 |
19.25 |
2.88 |
StrikeSwinging |
4.31 |
2.65 |
6.18 |
8.8 |
Sinker |
88.14 |
2151.30 |
240.72 |
17.63 |
11.22 |
StrikeCalled |
4.29 |
2.51 |
6.05 |
8.0 |
Sinker |
87.10 |
2171.42 |
251.43 |
19.35 |
7.94 |
StrikeSwinging |
4.25 |
2.72 |
6.10 |
8.4 |
Changeup |
86.02 |
2037.18 |
261.87 |
19.28 |
4.19 |
InPlay |
4.35 |
2.56 |
5.99 |
8.7 |
Changeup |
86.91 |
2048.47 |
246.70 |
15.62 |
7.93 |
StrikeCalled |
4.24 |
2.53 |
6.15 |
8.2 |
Curveball |
76.04 |
2009.47 |
114.35 |
-9.89 |
6.08 |
BallCalled |
4.23 |
2.53 |
6.08 |
3.8 |
Changeup |
86.12 |
2061.50 |
259.19 |
18.17 |
4.84 |
FoulBallNotFieldable |
4.24 |
2.66 |
6.27 |
8.6 |
Changeup |
86.82 |
2053.97 |
248.76 |
19.16 |
8.76 |
BallCalled |
4.17 |
2.60 |
6.26 |
8.3 |
Curveball |
77.77 |
1984.66 |
32.08 |
-2.99 |
-2.92 |
StrikeSwinging |
4.13 |
2.50 |
5.72 |
1.1 |
Sinker |
86.99 |
2084.23 |
242.00 |
17.22 |
10.51 |
FoulBallNotFieldable |
4.32 |
2.58 |
6.07 |
8.1 |
Curveball |
75.22 |
1991.71 |
67.37 |
-9.40 |
-2.17 |
InPlay |
4.28 |
2.56 |
5.96 |
2.2 |
# 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: 15
# Display the summary table
knitr::kable(pitch_summary, caption = "Summary Pitch Table for Aidan Krupp")
Summary Pitch Table for Aidan Krupp
Changeup |
60.00% |
9 |
4 |
5 |
44.44% |
55.56% |
85.73 |
2066.62 |
5.68 |
18.94 |
257.05 |
8.6 |
4.32 |
2.58 |
6.10 |
Curveball |
20.00% |
3 |
1 |
2 |
33.33% |
66.67% |
76.34 |
1995.28 |
0.33 |
-7.43 |
71.27 |
2.4 |
4.21 |
2.53 |
5.92 |
Sinker |
20.00% |
3 |
0 |
3 |
0.00% |
100.00% |
87.41 |
2135.65 |
9.89 |
18.07 |
244.72 |
8.2 |
4.29 |
2.60 |
6.07 |
# 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("Aidan Krupp maximum FB velocity: ", max_fb_velocity, "mph\n")
## Aidan Krupp maximum FB velocity: 88.14 mph
# Prepare data for plotting pitch locations
pitch_location_data <- Aidan_Krupp_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 Aidan Krupp",
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")
)
