# Filter the data for the pitcher Max Brulport
Brian_Foley_data <- data %>%
filter(Pitcher == "Brulport, 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 Brulport")
Detailed Pitch Table for Max Brulport
Slider |
76.91 |
2006.74 |
197.72 |
2.43 |
9.19 |
BallCalled |
5.44 |
-1.64 |
5.60 |
6.6 |
Slider |
77.15 |
2046.48 |
180.58 |
0.10 |
11.40 |
StrikeCalled |
5.34 |
-1.71 |
5.73 |
6.0 |
Slider |
77.73 |
2098.98 |
177.33 |
-0.36 |
9.27 |
StrikeCalled |
5.34 |
-1.73 |
5.70 |
5.9 |
Slider |
78.67 |
2073.26 |
209.41 |
3.72 |
8.21 |
FoulBallNotFieldable |
5.36 |
-1.80 |
5.61 |
7.0 |
Changeup |
83.03 |
1791.97 |
135.31 |
-7.67 |
8.97 |
InPlay |
5.52 |
-1.39 |
6.25 |
4.5 |
Changeup |
77.06 |
1275.43 |
142.92 |
-7.60 |
11.94 |
StrikeCalled |
5.11 |
-1.94 |
5.66 |
4.8 |
Changeup |
77.74 |
1348.29 |
100.29 |
-10.25 |
3.64 |
StrikeSwinging |
5.07 |
-1.87 |
5.64 |
3.3 |
Changeup |
77.25 |
1360.88 |
92.27 |
-9.30 |
2.09 |
BallinDirt |
5.13 |
-1.98 |
5.49 |
3.1 |
Changeup |
84.40 |
1896.57 |
154.94 |
-6.72 |
15.65 |
InPlay |
5.49 |
-1.69 |
5.92 |
5.2 |
Changeup |
84.92 |
1867.37 |
156.31 |
-5.81 |
14.48 |
BallCalled |
5.58 |
-1.52 |
5.97 |
5.2 |
Changeup |
78.08 |
1504.66 |
107.08 |
-10.09 |
4.74 |
FoulBallNotFieldable |
5.02 |
-1.90 |
5.68 |
3.6 |
Changeup |
78.12 |
1464.59 |
111.86 |
-12.32 |
6.66 |
BallinDirt |
5.13 |
-1.87 |
5.78 |
3.7 |
Changeup |
82.93 |
1881.78 |
162.41 |
-5.14 |
17.49 |
FoulBallNotFieldable |
5.35 |
-1.62 |
6.04 |
5.4 |
Changeup |
77.03 |
1380.55 |
162.91 |
-2.97 |
11.39 |
BallCalled |
5.17 |
-1.79 |
5.69 |
5.4 |
Changeup |
83.12 |
1797.33 |
152.21 |
-6.05 |
12.69 |
StrikeCalled |
5.37 |
-1.62 |
6.01 |
5.1 |
Changeup |
84.58 |
1855.88 |
139.15 |
-7.52 |
9.86 |
StrikeCalled |
5.43 |
-1.63 |
6.00 |
4.6 |
Changeup |
78.00 |
1525.54 |
122.61 |
-7.57 |
6.23 |
StrikeCalled |
5.07 |
-1.89 |
5.78 |
4.1 |
Changeup |
77.58 |
1458.78 |
128.52 |
-11.63 |
10.81 |
StrikeSwinging |
5.00 |
-1.81 |
5.68 |
4.3 |
Changeup |
83.39 |
1806.23 |
156.24 |
-5.41 |
13.60 |
StrikeCalled |
5.53 |
-1.55 |
5.82 |
5.2 |
Changeup |
77.46 |
1478.66 |
152.03 |
-5.30 |
11.68 |
BallCalled |
5.09 |
-1.84 |
5.65 |
5.1 |
Changeup |
83.75 |
1888.52 |
133.24 |
-8.64 |
9.33 |
InPlay |
5.43 |
-1.56 |
5.86 |
4.4 |
Changeup |
82.21 |
1899.16 |
162.58 |
-4.30 |
14.94 |
BallCalled |
5.39 |
-1.64 |
6.14 |
5.4 |
Changeup |
83.47 |
1810.87 |
132.83 |
-9.75 |
10.24 |
FoulBallNotFieldable |
5.40 |
-1.57 |
6.04 |
4.4 |
Changeup |
76.91 |
1358.74 |
168.16 |
-2.02 |
11.42 |
FoulBallNotFieldable |
5.04 |
-1.80 |
5.87 |
5.6 |
Changeup |
77.56 |
1330.39 |
106.89 |
-8.90 |
4.27 |
FoulBallNotFieldable |
4.87 |
-1.84 |
5.80 |
3.6 |
Changeup |
77.45 |
1382.09 |
153.60 |
-5.43 |
12.59 |
InPlay |
5.04 |
-1.73 |
5.82 |
5.1 |
Slider |
79.95 |
2126.06 |
163.31 |
-3.37 |
12.69 |
InPlay |
5.35 |
-1.61 |
5.74 |
5.4 |
Changeup |
83.98 |
1939.22 |
150.62 |
-7.16 |
13.98 |
BallCalled |
5.36 |
-1.63 |
5.98 |
5.0 |
Changeup |
83.74 |
1892.10 |
153.52 |
-7.41 |
16.14 |
StrikeCalled |
5.31 |
-1.65 |
5.89 |
5.1 |
Changeup |
77.14 |
1377.74 |
161.61 |
-3.24 |
11.49 |
BallCalled |
5.05 |
-1.85 |
5.84 |
5.4 |
Changeup |
83.30 |
2015.11 |
138.98 |
-10.91 |
13.87 |
BallCalled |
5.25 |
-1.61 |
6.20 |
4.6 |
Changeup |
83.07 |
1942.86 |
150.30 |
-8.12 |
15.51 |
InPlay |
5.27 |
-1.61 |
6.03 |
5.0 |
Slider |
78.97 |
2128.09 |
198.34 |
3.00 |
10.53 |
StrikeSwinging |
5.26 |
-1.65 |
5.73 |
6.6 |
Slider |
79.31 |
2253.35 |
195.25 |
2.35 |
10.04 |
BallCalled |
5.27 |
-1.53 |
5.75 |
6.5 |
Slider |
79.46 |
2153.37 |
202.66 |
3.99 |
11.02 |
BallCalled |
5.24 |
-1.67 |
5.89 |
6.8 |
Slider |
78.57 |
2168.66 |
184.84 |
1.21 |
15.96 |
InPlay |
5.23 |
-1.56 |
5.81 |
6.2 |
Changeup |
78.65 |
1421.21 |
154.38 |
-7.15 |
16.62 |
BallCalled |
4.99 |
-1.82 |
5.72 |
5.1 |
Changeup |
78.08 |
1247.89 |
148.58 |
-6.87 |
13.01 |
BallCalled |
4.95 |
-1.72 |
5.83 |
5.0 |
Slider |
79.29 |
2204.63 |
218.17 |
7.28 |
10.77 |
BallCalled |
5.26 |
-1.57 |
5.83 |
7.3 |
Changeup |
84.36 |
1999.80 |
137.21 |
-10.27 |
12.24 |
BallCalled |
5.40 |
-1.37 |
6.26 |
4.6 |
Changeup |
76.87 |
1425.89 |
158.60 |
-6.04 |
17.21 |
InPlay |
4.91 |
-1.91 |
5.69 |
5.3 |
# 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: 41
# Display the summary table
knitr::kable(pitch_summary, caption = "Summary Pitch Table for Max Brulport")
Summary Pitch Table for Max Brulport
Changeup |
75.61% |
31 |
12 |
19 |
38.71% |
61.29% |
80.49 |
1633.10 |
11.44 |
-7.34 |
141.55 |
4.7 |
5.22 |
-1.72 |
5.87 |
Slider |
24.39% |
10 |
4 |
6 |
40.00% |
60.00% |
78.60 |
2125.96 |
10.91 |
2.04 |
192.76 |
6.4 |
5.31 |
-1.65 |
5.74 |
# 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 Brulport maximum FB velocity: ", max_fb_velocity, "mph\n")
## Max Brulport 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 Brulport",
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")
)
