# Filter the data for the pitcher Adams
Adams_data <- Sanford64 %>%
filter(Pitcher == "Adams, Brandon")
# Create a detailed table for each pitch
detailed_pitch_table <- Adams_data %>%
select(AutoPitchType, RelSpeed, SpinRate, SpinAxis, HorzBreak, InducedVertBreak, PitchCall) %>%
rename(
ReleaseSpeed = RelSpeed,
Tilt = SpinAxis,
HorizontalBreak = HorzBreak,
InducedVerticalBreak = InducedVertBreak
) %>%
mutate(
ReleaseSpeed = round(ReleaseSpeed, 2),
SpinRate = round(SpinRate, 2),
Tilt = round(Tilt, 2),
HorizontalBreak = round(HorizontalBreak, 2),
InducedVerticalBreak = round(InducedVerticalBreak, 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 Adams")
Detailed Pitch Table for Adams
Four-Seam |
89.56 |
2250.99 |
200.08 |
7.02 |
20.33 |
StrikeSwinging |
6.7 |
Four-Seam |
91.06 |
2328.08 |
206.10 |
9.09 |
19.72 |
BallCalled |
6.9 |
Slider |
77.34 |
2502.76 |
70.55 |
-13.84 |
-3.50 |
BallCalled |
2.4 |
Slider |
77.56 |
2504.09 |
82.68 |
-15.49 |
-0.60 |
BallCalled |
2.8 |
Four-Seam |
89.72 |
2265.24 |
215.39 |
11.50 |
17.28 |
StrikeCalled |
7.2 |
Four-Seam |
90.27 |
2282.95 |
200.50 |
7.07 |
20.05 |
StrikeSwinging |
6.7 |
Four-Seam |
90.89 |
2296.09 |
205.29 |
9.45 |
21.10 |
StrikeCalled |
6.8 |
Slider |
79.06 |
2466.60 |
77.35 |
-15.54 |
-2.16 |
BallCalled |
2.6 |
Four-Seam |
91.59 |
2299.52 |
213.55 |
11.56 |
18.50 |
FoulBallNotFieldable |
7.1 |
Slider |
79.51 |
2528.51 |
81.77 |
-9.11 |
0.10 |
BallCalled |
2.7 |
Curveball |
79.50 |
2576.91 |
58.20 |
-12.57 |
-6.39 |
BallCalled |
1.9 |
Four-Seam |
91.12 |
2314.30 |
202.83 |
9.29 |
23.24 |
InPlay |
6.8 |
Four-Seam |
90.50 |
2292.58 |
218.56 |
14.90 |
19.87 |
InPlay |
7.3 |
Four-Seam |
89.35 |
2240.96 |
206.21 |
9.06 |
19.55 |
FoulBallNotFieldable |
6.9 |
Four-Seam |
89.65 |
2230.75 |
220.00 |
14.65 |
18.58 |
FoulBallNotFieldable |
7.3 |
Slider |
78.96 |
2510.10 |
81.75 |
-14.81 |
-0.75 |
StrikeSwinging |
2.7 |
Four-Seam |
89.26 |
2272.55 |
211.15 |
11.12 |
19.55 |
BallCalled |
7.0 |
Four-Seam |
89.76 |
2275.36 |
211.26 |
12.58 |
21.90 |
BallCalled |
7.0 |
Four-Seam |
89.69 |
2250.81 |
220.04 |
12.57 |
16.00 |
StrikeCalled |
7.3 |
Four-Seam |
90.24 |
2404.12 |
219.80 |
15.18 |
19.36 |
StrikeSwinging |
7.3 |
Slider |
79.28 |
2611.54 |
76.94 |
-11.60 |
-1.28 |
BallCalled |
2.6 |
Four-Seam |
89.46 |
2340.78 |
219.41 |
16.11 |
20.66 |
FoulBallNotFieldable |
7.3 |
Four-Seam |
89.20 |
2100.49 |
214.06 |
13.86 |
21.53 |
InPlay |
7.1 |
Four-Seam |
88.59 |
2217.71 |
211.47 |
11.45 |
19.80 |
BallCalled |
7.0 |
Four-Seam |
89.76 |
2224.44 |
214.05 |
13.13 |
20.56 |
BallCalled |
7.1 |
Four-Seam |
89.14 |
2203.14 |
216.82 |
13.13 |
18.57 |
StrikeCalled |
7.2 |
Four-Seam |
89.27 |
2194.89 |
217.24 |
14.66 |
20.37 |
InPlay |
7.2 |
# Create a summary table
pitch_summary <- detailed_pitch_table %>%
group_by(AutoPitchType) %>%
summarise(
TotalPitches = n(),
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
)
# Display the summary table
knitr::kable(pitch_summary, caption = "Summary Pitch Table for Adams")
Summary Pitch Table for Adams
Curveball |
1 |
1 |
0 |
100.00% |
0.00% |
79.50 |
2576.91 |
-6.39 |
-12.57 |
58.20 |
1.9 |
Four-Seam |
20 |
5 |
15 |
25.00% |
75.00% |
89.90 |
2264.29 |
19.83 |
11.87 |
212.19 |
7.1 |
Slider |
6 |
5 |
1 |
83.33% |
16.67% |
78.62 |
2520.60 |
-1.36 |
-13.40 |
78.51 |
2.6 |
# Prepare data for plotting pitch locations
pitch_location_data <- Adams_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) + # Increase point size
geom_rect(aes(xmin = -0.5, xmax = 0.5, ymin = 1.75, ymax = 3.25), fill = NA, color = "red", linetype = "solid", size = 1) + # Red box
geom_rect(aes(xmin = -0.75, xmax = 0.75, ymin = 1.5, ymax = 3.5), fill = NA, color = "black", linetype = "solid", size = 1) + # Black box
geom_rect(aes(xmin = -1.25, xmax = 1.25, ymin = 1.25, ymax = 3.75), fill = NA, color = "gray", linetype = "solid", size = 1) + # Gray box
scale_x_continuous(limits = c(-2, 2)) +
scale_y_continuous(limits = c(0, 5)) +
labs(title = "Pitch Locations for Adams",
x = "Horizontal Location (feet)",
y = "Vertical Location (feet)",
color = "Swing/Take",
shape = "Chase") +
facet_wrap(~ AutoPitchType) + # Create individual graphs for each pitch type
geom_text(aes(x = -1.75, y = 5, label = "RHH"), color = "black", size = 3, hjust = 0) + # Label for RHH
geom_text(aes(x = 1.75, y = 5, label = "LHH"), color = "black", size = 3, hjust = 1) + # Label for LHH
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
labs(title = "Pitch Movement for Adams",
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")
)
