# 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
Curveball |
75.18 |
2407.77 |
112.47 |
-17.17 |
8.79 |
StrikeCalled |
5.39 |
3.16 |
5.28 |
3.7 |
Slider |
76.80 |
2469.36 |
116.40 |
-17.46 |
10.25 |
StrikeSwinging |
5.52 |
2.95 |
5.29 |
3.9 |
Slider |
77.79 |
2522.34 |
100.96 |
-21.18 |
5.64 |
StrikeSwinging |
5.58 |
2.76 |
5.30 |
3.4 |
Changeup |
86.02 |
2216.73 |
227.10 |
14.95 |
15.16 |
InPlay |
5.62 |
2.98 |
5.95 |
7.6 |
Sinker |
86.07 |
2173.91 |
251.10 |
19.20 |
7.95 |
BallCalled |
5.62 |
2.79 |
5.71 |
8.4 |
Changeup |
84.45 |
2057.88 |
232.50 |
14.14 |
12.23 |
FoulBallNotFieldable |
5.56 |
2.83 |
5.95 |
7.8 |
Slider |
77.33 |
2565.37 |
103.15 |
-18.46 |
5.94 |
StrikeCalled |
5.53 |
2.99 |
5.32 |
3.4 |
Changeup |
77.83 |
1569.37 |
273.63 |
18.28 |
0.39 |
InPlay |
5.50 |
3.07 |
5.46 |
9.1 |
Slider |
78.37 |
2494.71 |
103.48 |
-15.46 |
5.26 |
BallCalled |
5.56 |
2.97 |
5.46 |
3.4 |
Changeup |
84.81 |
2120.81 |
232.55 |
15.51 |
13.32 |
StrikeCalled |
5.54 |
2.94 |
6.05 |
7.8 |
Slider |
76.91 |
2473.43 |
110.65 |
-19.15 |
8.83 |
StrikeSwinging |
5.53 |
3.04 |
5.34 |
3.7 |
Changeup |
78.29 |
1591.62 |
242.96 |
19.13 |
11.37 |
BallCalled |
5.38 |
3.25 |
5.51 |
8.1 |
Slider |
77.74 |
2466.54 |
104.97 |
-20.27 |
6.98 |
InPlay |
5.57 |
3.10 |
5.36 |
3.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: 13
# Display the summary table
knitr::kable(pitch_summary, caption = "Summary Pitch Table for Charlie Hale")
Summary Pitch Table for Charlie Hale
Changeup |
38.46% |
5 |
1 |
4 |
20.00% |
80.00% |
82.28 |
1911.28 |
10.49 |
16.40 |
241.75 |
8.1 |
5.52 |
3.01 |
5.78 |
Curveball |
7.69% |
1 |
0 |
1 |
0.00% |
100.00% |
75.18 |
2407.77 |
8.79 |
-17.17 |
112.47 |
3.7 |
5.39 |
3.16 |
5.28 |
Sinker |
7.69% |
1 |
1 |
0 |
100.00% |
0.00% |
86.07 |
2173.91 |
7.95 |
19.20 |
251.10 |
8.4 |
5.62 |
2.79 |
5.71 |
Slider |
46.15% |
6 |
1 |
5 |
16.67% |
83.33% |
77.49 |
2498.62 |
7.15 |
-18.66 |
106.60 |
3.5 |
5.55 |
2.97 |
5.34 |
# 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: 86.07 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, 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")
)
