# 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 |
74.44 |
2433.18 |
93.35 |
-19.74 |
2.81 |
InPlay |
5.42 |
2.89 |
5.12 |
3.1 |
Curveball |
76.54 |
2522.91 |
90.05 |
-12.39 |
1.40 |
StrikeCalled |
5.44 |
2.87 |
5.18 |
3.0 |
Slider |
76.96 |
2501.85 |
98.47 |
-17.84 |
4.24 |
FoulBallNotFieldable |
5.54 |
2.69 |
5.07 |
3.3 |
Curveball |
76.39 |
2521.00 |
96.18 |
-14.58 |
3.04 |
FoulBallNotFieldable |
5.50 |
2.92 |
4.99 |
3.2 |
Changeup |
86.31 |
2261.73 |
241.67 |
17.18 |
10.60 |
FoulBallNotFieldable |
5.66 |
2.42 |
5.93 |
8.1 |
Changeup |
77.36 |
1426.71 |
248.96 |
14.97 |
7.26 |
InPlay |
5.40 |
2.98 |
5.45 |
8.3 |
Curveball |
76.42 |
2589.70 |
79.62 |
-21.21 |
-2.26 |
BallCalled |
5.70 |
2.57 |
5.10 |
2.7 |
Curveball |
74.23 |
2425.73 |
84.40 |
-20.15 |
-0.45 |
BallCalled |
5.48 |
2.95 |
5.11 |
2.8 |
Changeup |
84.32 |
2267.33 |
242.44 |
14.52 |
8.84 |
StrikeCalled |
5.54 |
2.76 |
5.75 |
8.1 |
Curveball |
75.48 |
2463.87 |
83.68 |
-19.84 |
-0.42 |
BallCalled |
5.46 |
2.82 |
5.30 |
2.8 |
Changeup |
84.44 |
2238.94 |
247.54 |
17.26 |
8.53 |
BallCalled |
5.66 |
2.76 |
5.65 |
8.3 |
Slider |
76.77 |
2437.27 |
111.14 |
-13.86 |
7.02 |
BallCalled |
5.55 |
3.05 |
5.20 |
3.7 |
Changeup |
85.00 |
2203.68 |
240.13 |
12.58 |
8.40 |
StrikeCalled |
5.52 |
2.97 |
5.55 |
8.0 |
Slider |
76.41 |
2485.55 |
95.99 |
-17.75 |
3.44 |
StrikeSwinging |
5.57 |
2.98 |
5.09 |
3.2 |
Curveball |
76.43 |
2574.05 |
91.54 |
-18.16 |
2.12 |
BallCalled |
5.66 |
3.03 |
4.93 |
3.1 |
Changeup |
84.10 |
2227.05 |
236.79 |
9.70 |
7.57 |
BallCalled |
5.78 |
2.71 |
5.66 |
7.9 |
Curveball |
76.03 |
2489.57 |
83.69 |
-16.26 |
-0.28 |
BallCalled |
5.62 |
3.00 |
5.19 |
2.8 |
Changeup |
82.57 |
2067.07 |
247.59 |
16.12 |
8.14 |
FoulBallNotFieldable |
5.65 |
3.02 |
5.61 |
8.3 |
Slider |
75.79 |
2423.73 |
91.32 |
-16.66 |
2.11 |
InPlay |
5.50 |
3.09 |
5.05 |
3.0 |
# 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 == "BallCalled"),
Strikes = sum(PitchCall != "BallCalled"), # 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: 19
# Display the summary table
knitr::kable(pitch_summary, caption = "Summary Pitch Table for Charlie Hale")
Summary Pitch Table for Charlie Hale
Changeup |
36.84% |
7 |
2 |
5 |
28.57% |
71.43% |
83.44 |
2098.93 |
8.48 |
14.62 |
243.59 |
8.1 |
5.60 |
2.80 |
5.66 |
Curveball |
42.11% |
8 |
5 |
3 |
62.50% |
37.50% |
75.75 |
2502.50 |
0.74 |
-17.79 |
87.81 |
2.9 |
5.54 |
2.88 |
5.12 |
Slider |
21.05% |
4 |
1 |
3 |
25.00% |
75.00% |
76.48 |
2462.10 |
4.20 |
-16.53 |
99.23 |
3.3 |
5.54 |
2.95 |
5.10 |
# 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.75 | PitchSide > 0.75 | 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.75, xmax = 0.75, 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")
)
