# Filter the data for the pitcher Adams
Adams_data <- Danbury618 %>%
filter(Pitcher == "Adams, Brandon")
# Create a detailed table for each pitch
detailed_pitch_table <- Adams_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 Adams")
Detailed Pitch Table for Adams
Four-Seam |
89.81 |
2193.88 |
220.52 |
15.97 |
19.80 |
StrikeCalled |
5.36 |
2.27 |
7.12 |
7.4 |
Sinker |
90.06 |
2179.14 |
221.60 |
16.39 |
19.59 |
BallCalled |
5.33 |
2.32 |
7.14 |
7.4 |
Changeup |
81.38 |
2062.74 |
256.31 |
20.79 |
6.42 |
BallCalled |
5.03 |
2.76 |
6.83 |
8.5 |
Four-Seam |
89.96 |
2201.85 |
219.54 |
15.48 |
19.89 |
InPlay |
5.23 |
2.30 |
7.03 |
7.3 |
Curveball |
78.20 |
2373.10 |
62.90 |
-9.97 |
-3.66 |
StrikeSwinging |
5.26 |
2.23 |
6.23 |
2.1 |
Slider |
78.27 |
2500.10 |
108.86 |
-9.69 |
4.63 |
BallCalled |
5.18 |
2.35 |
6.49 |
3.6 |
Four-Seam |
90.81 |
2349.62 |
204.96 |
10.52 |
23.73 |
StrikeSwinging |
5.31 |
2.02 |
6.91 |
6.8 |
Four-Seam |
90.12 |
2235.28 |
208.42 |
10.88 |
21.18 |
InPlay |
5.38 |
1.97 |
7.24 |
6.9 |
Four-Seam |
88.92 |
2274.93 |
202.95 |
8.70 |
21.65 |
StrikeSwinging |
5.28 |
2.14 |
7.27 |
6.8 |
Four-Seam |
89.96 |
2343.14 |
209.27 |
12.16 |
22.84 |
StrikeSwinging |
5.40 |
1.90 |
7.38 |
7.0 |
Four-Seam |
90.00 |
2151.65 |
221.94 |
15.94 |
18.84 |
BallCalled |
5.39 |
2.00 |
7.14 |
7.4 |
Four-Seam |
89.81 |
2300.82 |
212.12 |
12.87 |
21.63 |
StrikeCalled |
5.28 |
2.04 |
7.33 |
7.1 |
Slider |
77.34 |
2331.65 |
108.53 |
-7.40 |
3.90 |
BallCalled |
5.20 |
2.27 |
6.55 |
3.6 |
Four-Seam |
90.39 |
2312.15 |
216.14 |
14.78 |
21.40 |
FoulBall |
5.38 |
1.98 |
7.19 |
7.2 |
Four-Seam |
89.63 |
2227.72 |
216.16 |
14.18 |
20.77 |
StrikeCalled |
5.20 |
1.92 |
7.46 |
7.2 |
Slider |
79.21 |
2433.87 |
92.56 |
-8.89 |
1.92 |
FoulBall |
5.16 |
2.16 |
6.56 |
3.1 |
Four-Seam |
89.21 |
2151.17 |
216.53 |
14.12 |
20.26 |
FoulBall |
5.34 |
2.18 |
7.49 |
7.2 |
Slider |
78.11 |
2519.63 |
81.46 |
-9.02 |
0.08 |
BallCalled |
5.19 |
2.34 |
6.74 |
2.7 |
Four-Seam |
90.50 |
2332.48 |
212.14 |
12.43 |
21.04 |
StrikeSwinging |
5.31 |
2.09 |
7.32 |
7.1 |
Four-Seam |
88.58 |
2331.18 |
209.02 |
11.59 |
22.22 |
BallCalled |
5.44 |
1.95 |
7.20 |
7.0 |
Four-Seam |
88.32 |
2191.33 |
217.58 |
13.65 |
19.07 |
FoulBall |
5.27 |
1.98 |
7.14 |
7.3 |
Slider |
77.99 |
2366.41 |
86.90 |
-5.93 |
1.11 |
StrikeCalled |
5.19 |
2.12 |
6.58 |
2.9 |
Four-Seam |
89.76 |
2289.32 |
211.42 |
12.16 |
21.12 |
InPlay |
5.33 |
1.98 |
7.30 |
7.0 |
Four-Seam |
88.79 |
2182.83 |
205.98 |
10.44 |
22.65 |
BallCalled |
5.26 |
2.02 |
7.72 |
6.9 |
Four-Seam |
89.16 |
2224.64 |
206.16 |
10.27 |
22.14 |
FoulBall |
5.10 |
2.19 |
7.59 |
6.9 |
Changeup |
81.52 |
2073.72 |
245.23 |
20.07 |
10.68 |
StrikeCalled |
4.99 |
2.31 |
7.33 |
8.2 |
Four-Seam |
90.12 |
2274.43 |
212.75 |
12.58 |
20.70 |
FoulBall |
5.24 |
1.95 |
7.06 |
7.1 |
Changeup |
80.74 |
1919.13 |
237.12 |
14.97 |
11.11 |
BallCalled |
5.01 |
2.56 |
6.95 |
7.9 |
Four-Seam |
88.77 |
2209.45 |
211.06 |
12.90 |
22.69 |
StrikeCalled |
5.16 |
2.14 |
7.65 |
7.0 |
Slider |
76.93 |
2304.47 |
93.97 |
-2.62 |
1.71 |
StrikeCalled |
5.18 |
2.24 |
6.70 |
3.1 |
Four-Seam |
89.51 |
2284.65 |
212.44 |
12.85 |
21.47 |
InPlay |
5.19 |
2.03 |
7.41 |
7.1 |
Four-Seam |
89.10 |
2205.09 |
216.99 |
13.98 |
19.81 |
StrikeCalled |
5.22 |
1.92 |
7.53 |
7.2 |
Four-Seam |
89.64 |
2299.79 |
209.02 |
11.43 |
21.89 |
StrikeSwinging |
5.21 |
2.03 |
7.16 |
7.0 |
Four-Seam |
88.92 |
2275.07 |
205.16 |
10.23 |
23.05 |
StrikeCalled |
5.27 |
2.04 |
7.29 |
6.8 |
Four-Seam |
86.04 |
2164.72 |
218.72 |
14.90 |
19.91 |
StrikeCalled |
5.32 |
2.10 |
7.12 |
7.3 |
Four-Seam |
87.99 |
2257.67 |
217.70 |
14.11 |
19.59 |
InPlay |
5.22 |
2.24 |
7.07 |
7.3 |
Four-Seam |
88.61 |
2243.23 |
212.57 |
12.26 |
20.38 |
FoulBall |
5.11 |
2.17 |
7.48 |
7.1 |
Changeup |
81.23 |
2027.11 |
244.26 |
16.81 |
9.55 |
InPlay |
4.95 |
2.46 |
7.08 |
8.1 |
Slider |
76.66 |
2363.17 |
86.01 |
-8.99 |
0.91 |
BallCalled |
5.13 |
2.18 |
6.48 |
2.9 |
Slider |
76.25 |
2413.40 |
89.10 |
-10.19 |
1.24 |
StrikeCalled |
5.20 |
2.29 |
6.73 |
3.0 |
Four-Seam |
90.06 |
2268.62 |
222.55 |
14.88 |
17.43 |
InPlay |
5.28 |
2.02 |
6.89 |
7.4 |
# 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\\n')
## Total number of pitches thrown: 41 \n\n
# Display the summary table
knitr::kable(pitch_summary, caption = "Summary Pitch Table for Adams")
Summary Pitch Table for Adams
Changeup |
9.76% |
4 |
2 |
2 |
50.00% |
50.00% |
81.22 |
2020.67 |
9.44 |
18.16 |
245.73 |
8.2 |
5.00 |
2.52 |
7.05 |
Curveball |
2.44% |
1 |
0 |
1 |
0.00% |
100.00% |
78.20 |
2373.10 |
-3.66 |
-9.97 |
62.90 |
2.1 |
5.26 |
2.23 |
6.23 |
Four-Seam |
65.85% |
27 |
3 |
24 |
11.11% |
88.89% |
89.35 |
2250.99 |
21.01 |
12.82 |
212.96 |
7.1 |
5.28 |
2.06 |
7.28 |
Sinker |
2.44% |
1 |
1 |
0 |
100.00% |
0.00% |
90.06 |
2179.14 |
19.59 |
16.39 |
221.60 |
7.4 |
5.33 |
2.32 |
7.14 |
Slider |
19.51% |
8 |
4 |
4 |
50.00% |
50.00% |
77.60 |
2404.09 |
1.94 |
-7.84 |
93.42 |
3.1 |
5.18 |
2.24 |
6.60 |
# 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('Adams maximum FB velocity: ', max_fb_velocity, '\\n')
## Adams maximum FB velocity: 90.81 \n
# 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)) +
coord_fixed(ratio = 1) + # Adjust ratio to shrink vertical distance
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')
)
