# Filter the data for the pitcher Eshleman
Simpson_data <- Keene616 %>%
filter(Pitcher == "Simpson, Max")
# Create a detailed table for each pitch
detailed_pitch_table <- Simpson_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 Simpson")
Detailed Pitch Table for Simpson
Changeup |
88.44 |
1874.99 |
257.02 |
15.12 |
4.62 |
BallCalled |
5.63 |
2.23 |
6.30 |
8.6 |
Sinker |
88.89 |
2054.25 |
236.83 |
17.57 |
12.74 |
StrikeCalled |
5.68 |
2.11 |
6.16 |
7.9 |
Sinker |
89.31 |
2012.68 |
237.79 |
17.11 |
12.00 |
BallCalled |
5.53 |
2.18 |
6.03 |
7.9 |
Sinker |
90.77 |
2124.15 |
242.59 |
20.36 |
11.84 |
StrikeCalled |
5.61 |
2.18 |
5.70 |
8.1 |
Curveball |
78.59 |
1824.90 |
40.99 |
-9.12 |
-8.85 |
StrikeSwinging |
5.79 |
1.84 |
5.65 |
1.4 |
Slider |
82.56 |
1847.15 |
126.61 |
-5.64 |
5.85 |
BallCalled |
5.69 |
2.05 |
5.88 |
4.2 |
Sinker |
88.98 |
1955.12 |
241.15 |
16.58 |
10.40 |
InPlay |
5.68 |
2.08 |
6.07 |
8.0 |
Changeup |
87.99 |
1989.15 |
243.60 |
19.90 |
11.20 |
BallCalled |
5.57 |
2.30 |
6.02 |
8.1 |
Changeup |
87.85 |
1975.24 |
247.18 |
20.56 |
10.02 |
BallCalled |
5.57 |
2.14 |
5.93 |
8.2 |
Sinker |
88.14 |
1964.02 |
243.23 |
18.48 |
10.65 |
FoulBallFieldable |
5.49 |
2.22 |
6.20 |
8.1 |
Changeup |
86.72 |
1912.25 |
247.37 |
16.18 |
8.09 |
BallCalled |
5.59 |
2.17 |
6.07 |
8.2 |
Sinker |
88.57 |
1941.74 |
256.39 |
18.95 |
5.86 |
InPlay |
5.49 |
2.18 |
6.18 |
8.5 |
Sinker |
88.21 |
1907.07 |
235.82 |
16.47 |
12.39 |
BallCalled |
5.70 |
2.17 |
6.03 |
7.9 |
Curveball |
76.38 |
1793.67 |
39.50 |
-7.73 |
-7.75 |
StrikeCalled |
5.78 |
1.82 |
5.63 |
1.3 |
Changeup |
88.03 |
1854.98 |
252.53 |
17.35 |
6.69 |
InPlay |
5.37 |
2.20 |
6.36 |
8.4 |
Curveball |
76.02 |
1728.46 |
48.19 |
-10.17 |
-7.58 |
BallCalled |
5.82 |
1.77 |
5.72 |
1.6 |
Curveball |
77.17 |
1795.76 |
54.17 |
-10.30 |
-5.97 |
StrikeCalled |
5.74 |
2.09 |
5.80 |
1.8 |
Sinker |
88.25 |
1942.60 |
245.44 |
17.10 |
9.02 |
StrikeSwinging |
5.53 |
2.10 |
6.04 |
8.2 |
Changeup |
88.48 |
1863.33 |
251.66 |
18.10 |
7.22 |
BallCalled |
5.51 |
2.20 |
6.01 |
8.4 |
Curveball |
78.39 |
1756.56 |
54.58 |
-14.36 |
-8.71 |
StrikeSwinging |
5.65 |
1.76 |
5.79 |
1.8 |
Curveball |
76.94 |
1663.42 |
52.31 |
-7.04 |
-3.99 |
InPlay |
5.97 |
1.43 |
5.85 |
1.7 |
Changeup |
87.41 |
1881.53 |
251.42 |
19.23 |
7.61 |
FoulBallNotFieldable |
5.55 |
1.91 |
6.16 |
8.4 |
Changeup |
87.52 |
1906.16 |
241.59 |
15.09 |
9.34 |
FoulBallNotFieldable |
5.72 |
1.89 |
6.01 |
8.1 |
Slider |
81.37 |
2067.11 |
150.10 |
-3.61 |
7.70 |
StrikeSwinging |
5.58 |
1.68 |
5.58 |
5.0 |
Changeup |
87.41 |
1993.62 |
250.16 |
17.50 |
7.54 |
StrikeCalled |
5.52 |
1.96 |
6.05 |
8.3 |
Sinker |
88.96 |
2017.35 |
249.77 |
17.94 |
7.82 |
FoulBallNotFieldable |
5.53 |
2.00 |
6.10 |
8.3 |
Sinker |
88.80 |
1975.91 |
245.90 |
15.55 |
8.11 |
InPlay |
5.65 |
1.67 |
6.08 |
8.2 |
Sinker |
88.84 |
1924.95 |
245.80 |
16.65 |
8.63 |
FoulBallNotFieldable |
5.48 |
2.11 |
6.28 |
8.2 |
Curveball |
77.35 |
1847.11 |
61.74 |
-11.74 |
-4.76 |
StrikeCalled |
5.84 |
1.81 |
5.59 |
2.1 |
Curveball |
78.88 |
1873.04 |
42.37 |
-6.42 |
-5.50 |
BallCalled |
5.72 |
1.85 |
5.88 |
1.4 |
Four-Seam |
87.69 |
2111.79 |
212.59 |
10.91 |
18.31 |
BallCalled |
5.90 |
1.73 |
6.45 |
7.1 |
Curveball |
78.03 |
1858.02 |
43.95 |
-8.61 |
-7.40 |
InPlay |
5.92 |
1.70 |
5.62 |
1.5 |
Sinker |
88.06 |
2028.43 |
245.68 |
16.00 |
8.47 |
FoulBallNotFieldable |
5.51 |
1.98 |
6.14 |
8.2 |
Changeup |
86.93 |
2042.14 |
242.25 |
15.61 |
9.40 |
BallCalled |
5.51 |
2.13 |
6.07 |
8.1 |
Four-Seam |
87.15 |
2063.53 |
209.46 |
8.65 |
16.57 |
BallCalled |
5.83 |
1.75 |
6.30 |
7.0 |
Changeup |
86.31 |
2010.77 |
246.92 |
15.61 |
7.90 |
FoulBallNotFieldable |
5.50 |
2.14 |
6.12 |
8.2 |
Sinker |
87.40 |
2076.40 |
222.67 |
12.80 |
15.01 |
InPlay |
5.70 |
1.79 |
6.07 |
7.4 |
Changeup |
87.50 |
1952.43 |
248.10 |
18.96 |
8.95 |
BallCalled |
5.68 |
1.92 |
6.15 |
8.3 |
Changeup |
87.65 |
1930.56 |
240.16 |
16.95 |
11.05 |
FoulBallNotFieldable |
5.64 |
1.89 |
6.11 |
8.0 |
Slider |
82.34 |
2026.74 |
128.08 |
-4.38 |
5.25 |
BallCalled |
5.61 |
2.09 |
5.74 |
4.3 |
Changeup |
85.94 |
1975.24 |
239.03 |
15.96 |
11.10 |
StrikeSwinging |
5.61 |
2.06 |
6.14 |
8.0 |
Four-Seam |
87.58 |
2153.25 |
205.28 |
9.10 |
20.61 |
FoulBallNotFieldable |
6.03 |
1.38 |
6.14 |
6.8 |
Curveball |
76.59 |
1835.24 |
39.05 |
-8.51 |
-8.84 |
FoulBallNotFieldable |
5.89 |
1.56 |
5.74 |
1.3 |
Sinker |
87.05 |
1956.28 |
231.72 |
14.10 |
12.42 |
BallCalled |
5.72 |
1.99 |
6.18 |
7.7 |
Changeup |
87.51 |
2101.09 |
248.14 |
16.35 |
7.85 |
InPlay |
5.58 |
1.76 |
6.19 |
8.3 |
Changeup |
86.94 |
2085.80 |
221.18 |
12.25 |
15.24 |
StrikeCalled |
5.62 |
1.73 |
6.11 |
7.4 |
Changeup |
87.45 |
2111.16 |
248.53 |
16.85 |
7.87 |
InPlay |
5.58 |
2.04 |
6.10 |
8.3 |
Changeup |
87.39 |
2073.46 |
263.81 |
18.62 |
3.22 |
FoulBallNotFieldable |
5.48 |
2.04 |
6.13 |
8.8 |
Sinker |
88.55 |
1971.71 |
246.68 |
18.31 |
9.16 |
InPlay |
5.50 |
2.00 |
6.15 |
8.2 |
Curveball |
75.93 |
1853.17 |
51.09 |
-14.19 |
-9.99 |
StrikeCalled |
5.79 |
1.69 |
5.74 |
1.7 |
Curveball |
77.38 |
1869.92 |
52.15 |
-11.73 |
-7.66 |
BallCalled |
5.81 |
1.72 |
5.79 |
1.7 |
Changeup |
86.91 |
1947.70 |
252.70 |
18.33 |
6.91 |
StrikeSwinging |
5.58 |
2.05 |
5.98 |
8.4 |
Sinker |
87.02 |
2002.22 |
223.70 |
13.09 |
14.95 |
StrikeCalled |
5.77 |
1.77 |
6.15 |
7.5 |
Curveball |
76.19 |
1818.06 |
54.41 |
-7.87 |
-4.21 |
BallCalled |
5.90 |
1.50 |
5.59 |
1.8 |
Sinker |
88.23 |
2111.62 |
239.99 |
18.26 |
11.71 |
HitByPitch |
5.75 |
2.04 |
6.06 |
8.0 |
Changeup |
86.64 |
2033.31 |
252.60 |
17.69 |
6.88 |
FoulBallNotFieldable |
5.61 |
2.04 |
6.28 |
8.4 |
Changeup |
86.82 |
2042.32 |
242.57 |
18.03 |
10.54 |
FoulBallNotFieldable |
5.81 |
1.81 |
6.17 |
8.1 |
Curveball |
77.79 |
1885.58 |
32.62 |
-6.16 |
-8.02 |
StrikeSwinging |
5.93 |
1.44 |
5.83 |
1.1 |
Sinker |
87.60 |
2023.84 |
239.15 |
17.83 |
12.05 |
FoulBallNotFieldable |
5.56 |
1.86 |
6.09 |
8.0 |
Curveball |
75.13 |
1774.56 |
50.64 |
-12.62 |
-8.69 |
StrikeCalled |
5.81 |
1.58 |
5.87 |
1.7 |
Four-Seam |
88.61 |
2072.33 |
217.62 |
11.53 |
16.24 |
FoulBallNotFieldable |
5.82 |
1.74 |
6.16 |
7.3 |
Curveball |
78.46 |
1864.20 |
33.99 |
-8.40 |
-10.97 |
StrikeSwinging |
5.74 |
1.64 |
5.89 |
1.1 |
# 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)
## Total number of pitches thrown: 62
# Display the summary table
knitr::kable(pitch_summary, caption = "Summary Pitch Table for Simpson")
Summary Pitch Table for Simpson
Changeup |
33.87% |
21 |
7 |
14 |
33.33% |
66.67% |
87.33 |
1978.92 |
8.54 |
17.15 |
247.07 |
8.2 |
5.58 |
2.03 |
6.12 |
Curveball |
25.81% |
16 |
4 |
12 |
25.00% |
75.00% |
77.20 |
1815.10 |
-7.43 |
-9.69 |
46.98 |
1.6 |
5.82 |
1.70 |
5.75 |
Four-Seam |
6.45% |
4 |
2 |
2 |
50.00% |
50.00% |
87.76 |
2100.22 |
17.93 |
10.05 |
211.24 |
7.0 |
5.90 |
1.65 |
6.26 |
Sinker |
29.03% |
18 |
3 |
15 |
16.67% |
83.33% |
88.42 |
1999.46 |
10.73 |
16.84 |
240.57 |
8.0 |
5.60 |
2.02 |
6.10 |
Slider |
4.84% |
3 |
2 |
1 |
66.67% |
33.33% |
82.09 |
1980.33 |
6.27 |
-4.54 |
134.93 |
4.5 |
5.63 |
1.94 |
5.73 |
# 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('Simpson maximum FB velocity: ', max_fb_velocity)
## Simpson maximum FB velocity: 90.77
# Prepare data for plotting pitch locations
pitch_location_data <- Simpson_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 Simpson',
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 Eshleman',
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')
)
