# Filter the data for the pitcher Charlie Hale
Brian_Foley_data <- data %>%
filter(Pitcher == "Hale, Charlie")
# 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 Charlie Hale")
Detailed Pitch Table for Charlie Hale
Slider |
76.58 |
2285.59 |
87.62 |
-7.08 |
1.40 |
StrikeCalled |
5.56 |
2.84 |
5.17 |
2.9 |
Changeup |
77.21 |
1218.62 |
257.43 |
14.93 |
4.89 |
StrikeSwinging |
5.37 |
2.99 |
5.16 |
8.6 |
Changeup |
77.55 |
1349.67 |
279.28 |
12.07 |
-0.44 |
FoulBallNotFieldable |
5.53 |
2.92 |
5.30 |
9.3 |
Changeup |
85.71 |
2125.44 |
227.22 |
9.57 |
9.92 |
BallCalled |
5.79 |
2.73 |
5.65 |
7.6 |
Slider |
77.62 |
2430.75 |
95.38 |
-14.95 |
2.77 |
BallCalled |
5.60 |
2.97 |
5.13 |
3.2 |
Changeup |
75.64 |
1141.29 |
326.28 |
4.81 |
-5.78 |
BallCalled |
5.41 |
2.92 |
5.14 |
10.9 |
Changeup |
84.87 |
2047.51 |
242.17 |
14.78 |
8.91 |
BallCalled |
5.47 |
3.01 |
5.48 |
8.1 |
Changeup |
84.55 |
2078.12 |
238.15 |
17.33 |
11.99 |
StrikeSwinging |
5.49 |
3.22 |
5.41 |
7.9 |
Slider |
76.68 |
2346.82 |
99.27 |
-11.31 |
3.47 |
StrikeCalled |
5.48 |
3.12 |
4.96 |
3.3 |
Changeup |
76.60 |
1255.41 |
280.53 |
16.01 |
-1.42 |
InPlay |
5.39 |
3.22 |
5.16 |
9.4 |
Changeup |
84.72 |
1989.97 |
236.59 |
14.23 |
10.70 |
BallCalled |
5.48 |
3.28 |
6.02 |
7.9 |
Curveball |
76.63 |
2285.05 |
80.52 |
-9.97 |
-0.13 |
BallCalled |
5.39 |
3.17 |
5.28 |
2.7 |
Changeup |
84.88 |
2085.91 |
258.12 |
17.47 |
4.83 |
BallCalled |
5.58 |
2.99 |
5.96 |
8.6 |
Changeup |
84.86 |
2010.95 |
232.00 |
12.44 |
10.94 |
StrikeCalled |
5.53 |
3.06 |
5.76 |
7.7 |
Changeup |
83.99 |
2036.31 |
253.34 |
18.56 |
6.79 |
FoulBallNotFieldable |
5.51 |
3.01 |
5.68 |
8.4 |
Slider |
77.42 |
2431.82 |
90.97 |
-17.53 |
1.79 |
BallCalled |
5.47 |
3.12 |
5.22 |
3.0 |
Changeup |
76.73 |
1378.69 |
271.66 |
10.94 |
1.18 |
BallCalled |
5.53 |
3.41 |
4.96 |
9.1 |
Changeup |
75.63 |
1264.98 |
305.51 |
6.82 |
-3.29 |
FoulBallNotFieldable |
5.51 |
3.21 |
5.26 |
10.2 |
Changeup |
76.70 |
1211.51 |
281.42 |
7.53 |
0.03 |
StrikeCalled |
5.51 |
3.24 |
5.10 |
9.4 |
Changeup |
77.19 |
1278.83 |
276.83 |
11.51 |
0.21 |
BallCalled |
5.44 |
3.35 |
5.22 |
9.2 |
Slider |
76.86 |
2441.43 |
93.96 |
-17.75 |
2.80 |
InPlay |
5.41 |
3.39 |
5.12 |
3.1 |
Slider |
76.44 |
2337.60 |
92.92 |
-17.93 |
2.55 |
BallCalled |
5.48 |
3.21 |
5.16 |
3.1 |
Curveball |
74.94 |
2346.73 |
83.41 |
-13.35 |
0.12 |
StrikeCalled |
5.45 |
3.17 |
5.02 |
2.8 |
Changeup |
84.73 |
2130.14 |
246.08 |
14.94 |
8.01 |
BallCalled |
5.61 |
3.07 |
5.91 |
8.2 |
Slider |
76.06 |
2441.20 |
113.13 |
-12.37 |
6.91 |
BallCalled |
5.43 |
3.21 |
5.26 |
3.8 |
Changeup |
83.66 |
2146.76 |
241.97 |
13.14 |
8.44 |
InPlay |
5.50 |
3.11 |
5.72 |
8.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 %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: 26
# Display the summary table
knitr::kable(pitch_summary, caption = "Summary Pitch Table for Charlie Hale")
Summary Pitch Table for Charlie Hale
Changeup |
65.38% |
17 |
8 |
9 |
47.06% |
52.94% |
80.90 |
1691.18 |
4.47 |
12.77 |
262.03 |
8.7 |
5.51 |
3.10 |
5.46 |
Curveball |
7.69% |
2 |
1 |
1 |
50.00% |
50.00% |
75.78 |
2315.89 |
-0.01 |
-11.66 |
81.97 |
2.8 |
5.42 |
3.17 |
5.15 |
Slider |
26.92% |
7 |
4 |
3 |
57.14% |
42.86% |
76.81 |
2387.89 |
3.10 |
-14.13 |
96.18 |
3.2 |
5.49 |
3.12 |
5.15 |
# 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("Charlie Hale maximum FB velocity: ", max_fb_velocity, "mph\n")
## Charlie Hale 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", "FoulBallNonSwinging", "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 Charlie Hale",
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")
)
