# 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 |
74.77 |
2471.27 |
100.64 |
-24.73 |
6.52 |
StrikeCalled |
5.46 |
2.79 |
5.44 |
3.4 |
Slider |
76.94 |
2529.81 |
89.19 |
-21.51 |
1.55 |
BallCalled |
5.47 |
2.81 |
5.57 |
3.0 |
Changeup |
84.78 |
2157.54 |
253.67 |
20.06 |
7.62 |
InPlay |
5.48 |
2.82 |
6.00 |
8.5 |
Changeup |
84.13 |
2072.25 |
243.11 |
16.52 |
10.14 |
BallCalled |
5.41 |
3.29 |
5.53 |
8.1 |
Curveball |
73.96 |
2381.93 |
101.61 |
-15.29 |
5.06 |
StrikeSwinging |
5.41 |
3.03 |
5.35 |
3.4 |
Changeup |
76.87 |
1482.29 |
281.37 |
18.81 |
-2.00 |
InPlay |
5.38 |
2.86 |
5.52 |
9.4 |
Curveball |
75.66 |
2478.59 |
91.64 |
-18.04 |
2.22 |
InPlay |
5.46 |
2.83 |
5.53 |
3.1 |
Changeup |
83.43 |
2115.90 |
251.92 |
15.15 |
6.39 |
StrikeSwinging |
5.41 |
2.85 |
6.11 |
8.4 |
Changeup |
77.68 |
1451.14 |
282.73 |
14.40 |
-1.53 |
BallCalled |
5.41 |
2.81 |
5.53 |
9.4 |
Curveball |
74.50 |
2503.02 |
97.08 |
-16.23 |
3.76 |
StrikeSwinging |
5.47 |
3.01 |
5.58 |
3.2 |
Changeup |
76.99 |
1514.95 |
271.56 |
12.03 |
1.15 |
StrikeSwinging |
5.41 |
3.03 |
5.75 |
9.1 |
Changeup |
86.00 |
2171.68 |
226.69 |
11.17 |
11.80 |
InPlay |
5.58 |
2.72 |
6.17 |
7.6 |
Slider |
75.10 |
2410.08 |
88.49 |
-21.37 |
1.06 |
StrikeCalled |
5.53 |
2.96 |
5.51 |
2.9 |
Slider |
76.38 |
2456.73 |
97.86 |
-17.77 |
4.09 |
BallCalled |
5.57 |
2.67 |
5.58 |
3.3 |
Curveball |
75.54 |
2563.34 |
91.67 |
-22.36 |
2.23 |
StrikeCalled |
5.60 |
2.80 |
5.47 |
3.1 |
Slider |
84.57 |
2218.82 |
229.04 |
6.88 |
7.23 |
BallCalled |
5.69 |
2.63 |
6.06 |
7.6 |
Changeup |
78.08 |
1525.36 |
264.13 |
11.56 |
2.72 |
StrikeSwinging |
5.48 |
2.76 |
5.79 |
8.8 |
Changeup |
78.21 |
1557.28 |
247.93 |
14.79 |
7.59 |
StrikeSwinging |
5.41 |
3.00 |
5.65 |
8.3 |
Slider |
76.03 |
2510.04 |
88.52 |
-22.49 |
1.12 |
BallCalled |
5.59 |
2.79 |
5.33 |
3.0 |
Changeup |
77.45 |
1554.20 |
253.34 |
11.81 |
5.19 |
FoulBallNotFieldable |
5.55 |
2.90 |
5.78 |
8.4 |
Changeup |
85.82 |
2218.83 |
236.62 |
11.68 |
9.13 |
BallCalled |
5.65 |
2.92 |
5.81 |
7.9 |
Changeup |
77.33 |
1605.58 |
259.02 |
14.88 |
4.44 |
BallCalled |
5.45 |
2.91 |
5.67 |
8.6 |
Slider |
77.63 |
2518.35 |
98.22 |
-21.22 |
4.77 |
BallCalled |
5.50 |
2.90 |
5.43 |
3.3 |
Curveball |
75.17 |
2465.90 |
94.97 |
-17.54 |
3.15 |
StrikeCalled |
5.60 |
2.85 |
5.49 |
3.2 |
Changeup |
77.06 |
1553.52 |
247.37 |
10.21 |
5.92 |
FoulBallNotFieldable |
5.48 |
3.01 |
5.71 |
8.2 |
Curveball |
76.26 |
2605.05 |
92.01 |
-17.70 |
2.38 |
BallCalled |
5.67 |
2.78 |
5.49 |
3.1 |
Changeup |
84.88 |
2253.33 |
246.41 |
15.31 |
8.05 |
BallCalled |
5.75 |
2.78 |
5.99 |
8.2 |
Slider |
77.19 |
2529.56 |
93.92 |
-20.23 |
3.08 |
InPlay |
5.61 |
2.99 |
5.43 |
3.1 |
Changeup |
83.21 |
2199.00 |
241.51 |
13.73 |
8.86 |
InPlay |
5.51 |
3.21 |
6.09 |
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: 29
# Display the summary table
knitr::kable(pitch_summary, caption = "Summary Pitch Table for Charlie Hale")
Summary Pitch Table for Charlie Hale
Changeup |
51.72% |
15 |
5 |
10 |
33.33% |
66.67% |
80.79 |
1828.86 |
5.70 |
14.14 |
253.83 |
8.5 |
5.49 |
2.92 |
5.81 |
Curveball |
20.69% |
6 |
1 |
5 |
16.67% |
83.33% |
75.18 |
2499.64 |
3.13 |
-17.86 |
94.83 |
3.2 |
5.54 |
2.88 |
5.48 |
Slider |
27.59% |
8 |
5 |
3 |
62.50% |
37.50% |
77.33 |
2455.58 |
3.68 |
-17.80 |
110.74 |
3.7 |
5.55 |
2.82 |
5.54 |
# 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("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", "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 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, 26)) + # 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")
)
