# Filter the data for the pitcher Max Moss
Brian_Foley_data <- data %>%
filter(Pitcher == "Moss, Max")
# 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 Max Moss")
Detailed Pitch Table for Max Moss
Changeup |
83.26 |
1698.04 |
246.69 |
18.36 |
9.30 |
StrikeCalled |
4.92 |
3.59 |
5.14 |
8.2 |
Changeup |
76.18 |
1759.36 |
252.32 |
18.58 |
7.53 |
InPlay |
4.71 |
3.61 |
5.39 |
8.4 |
Changeup |
83.56 |
1737.09 |
257.08 |
21.15 |
6.28 |
StrikeCalled |
4.81 |
3.56 |
5.14 |
8.6 |
Changeup |
77.09 |
1741.24 |
255.65 |
19.60 |
6.56 |
BallCalled |
4.69 |
3.59 |
5.53 |
8.5 |
Changeup |
76.83 |
2008.52 |
262.86 |
22.14 |
4.40 |
StrikeSwinging |
4.71 |
3.59 |
5.40 |
8.8 |
Changeup |
76.20 |
1683.12 |
268.32 |
20.86 |
2.22 |
BallCalled |
4.62 |
3.63 |
5.30 |
8.9 |
Curveball |
75.17 |
2176.03 |
86.50 |
-6.59 |
1.20 |
HitByPitch |
4.70 |
3.55 |
5.02 |
2.9 |
Changeup |
84.56 |
1731.99 |
250.59 |
16.56 |
7.31 |
BallCalled |
4.86 |
3.79 |
5.22 |
8.4 |
Changeup |
76.64 |
1918.29 |
266.53 |
20.31 |
2.90 |
BallCalled |
4.59 |
3.69 |
5.48 |
8.9 |
Changeup |
76.83 |
1839.89 |
266.56 |
21.05 |
2.91 |
BallCalled |
4.67 |
3.49 |
5.31 |
8.9 |
Changeup |
86.55 |
1914.12 |
246.28 |
19.54 |
9.88 |
BallCalled |
4.82 |
3.56 |
5.21 |
8.2 |
Changeup |
86.18 |
1976.17 |
248.58 |
20.97 |
9.63 |
StrikeCalled |
4.96 |
3.50 |
5.33 |
8.3 |
Changeup |
85.18 |
1968.15 |
238.32 |
19.24 |
13.27 |
BallCalled |
4.83 |
3.71 |
5.22 |
7.9 |
Changeup |
78.51 |
1959.22 |
264.89 |
22.36 |
3.57 |
BallCalled |
4.56 |
3.63 |
5.58 |
8.8 |
Changeup |
84.51 |
1840.23 |
255.33 |
20.38 |
6.72 |
FoulBallNotFieldable |
4.89 |
3.56 |
5.27 |
8.5 |
Slider |
75.84 |
2220.54 |
91.90 |
-7.98 |
1.92 |
InPlay |
4.65 |
3.66 |
5.12 |
3.1 |
Changeup |
83.10 |
1712.68 |
236.53 |
15.25 |
11.44 |
StrikeCalled |
4.85 |
3.52 |
5.00 |
7.9 |
Changeup |
84.45 |
1792.42 |
253.68 |
21.35 |
7.58 |
StrikeCalled |
4.78 |
3.50 |
5.14 |
8.5 |
Changeup |
76.92 |
1727.69 |
274.05 |
17.60 |
0.35 |
BallCalled |
4.52 |
3.80 |
4.92 |
9.1 |
Changeup |
77.27 |
1844.78 |
267.09 |
20.50 |
2.63 |
FoulBallNotFieldable |
4.63 |
3.76 |
4.93 |
8.9 |
Changeup |
85.70 |
1795.69 |
230.60 |
14.97 |
13.60 |
StrikeSwinging |
4.87 |
3.53 |
5.23 |
7.7 |
Changeup |
84.51 |
1791.16 |
222.75 |
13.02 |
15.42 |
FoulBallNotFieldable |
4.94 |
3.56 |
5.20 |
7.4 |
Changeup |
77.65 |
1726.19 |
262.92 |
18.37 |
3.78 |
InPlay |
4.70 |
3.56 |
5.32 |
8.8 |
Changeup |
85.50 |
1730.70 |
258.88 |
18.69 |
4.88 |
BallCalled |
4.92 |
3.55 |
5.19 |
8.6 |
Changeup |
85.40 |
1758.29 |
235.90 |
16.41 |
12.36 |
BallCalled |
4.80 |
3.68 |
5.10 |
7.9 |
Changeup |
76.34 |
1553.27 |
245.29 |
16.46 |
9.17 |
BallCalled |
4.64 |
3.79 |
5.21 |
8.2 |
Changeup |
85.24 |
1886.61 |
250.12 |
18.97 |
8.16 |
BallCalled |
4.92 |
3.45 |
5.18 |
8.3 |
Changeup |
85.36 |
1841.67 |
255.51 |
15.82 |
5.33 |
InPlay |
4.83 |
3.57 |
5.30 |
8.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: 28
# Display the summary table
knitr::kable(pitch_summary, caption = "Summary Pitch Table for Max Moss")
Summary Pitch Table for Max Moss
Changeup |
92.86% |
26 |
13 |
13 |
50.00% |
50.00% |
81.52 |
1805.25 |
7.20 |
18.79 |
252.82 |
8.4 |
4.77 |
3.61 |
5.24 |
Curveball |
3.57% |
1 |
0 |
1 |
0.00% |
100.00% |
75.17 |
2176.03 |
1.20 |
-6.59 |
86.50 |
2.9 |
4.70 |
3.55 |
5.02 |
Slider |
3.57% |
1 |
0 |
1 |
0.00% |
100.00% |
75.84 |
2220.54 |
1.92 |
-7.98 |
91.90 |
3.1 |
4.65 |
3.66 |
5.12 |
# 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("Max Moss maximum FB velocity: ", max_fb_velocity, "mph\n")
## Max Moss maximum FB velocity: -Inf 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 Max Moss",
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")
)
