# Filter the data for the pitcher Yoon Chae
Brian_Foley_data <- data %>%
filter(Pitcher == "Chae, Yoon")
# 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 Yoon Chae")
Detailed Pitch Table for Yoon Chae
Curveball |
70.85 |
1586.25 |
48.95 |
-5.81 |
-3.25 |
BallCalled |
5.56 |
0.84 |
4.50 |
1.6 |
Changeup |
80.64 |
2143.45 |
222.88 |
15.78 |
18.26 |
StrikeCalled |
5.67 |
1.33 |
5.10 |
7.4 |
Curveball |
71.67 |
1762.22 |
68.74 |
-4.19 |
0.30 |
InPlay |
5.58 |
0.86 |
4.61 |
2.3 |
Changeup |
73.02 |
1657.02 |
232.27 |
9.78 |
9.01 |
BallCalled |
5.52 |
1.50 |
4.87 |
7.7 |
NA |
72.60 |
1767.29 |
NA |
NA |
NA |
BallCalled |
5.71 |
1.27 |
4.86 |
NA |
Changeup |
81.62 |
2142.20 |
217.20 |
13.66 |
19.32 |
StrikeCalled |
5.70 |
0.89 |
5.09 |
7.2 |
Changeup |
82.70 |
2205.65 |
219.40 |
12.67 |
16.66 |
StrikeCalled |
5.54 |
1.16 |
5.08 |
7.3 |
Changeup |
75.08 |
1589.46 |
216.54 |
8.08 |
12.35 |
FoulBallNotFieldable |
5.51 |
1.02 |
4.84 |
7.2 |
Four-Seam |
83.74 |
2197.85 |
204.93 |
9.25 |
21.41 |
BallCalled |
5.67 |
0.93 |
5.23 |
6.8 |
Changeup |
82.34 |
2179.57 |
238.87 |
19.47 |
13.20 |
BallCalled |
5.68 |
1.00 |
5.22 |
8.0 |
Curveball |
74.10 |
1894.70 |
95.66 |
-2.88 |
2.18 |
StrikeCalled |
5.53 |
1.00 |
4.67 |
3.2 |
Changeup |
82.84 |
2216.35 |
212.31 |
11.44 |
19.39 |
FoulBallNotFieldable |
5.62 |
0.79 |
5.32 |
7.1 |
Changeup |
75.09 |
1686.22 |
257.31 |
17.06 |
5.05 |
BallCalled |
5.33 |
1.10 |
5.21 |
8.6 |
# 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 Yoon Chae")
Summary Pitch Table for Yoon Chae
Changeup |
61.54% |
8 |
3 |
5 |
37.50% |
62.50% |
79.17 |
1977.49 |
14.15 |
13.49 |
227.10 |
7.6 |
5.57 |
1.10 |
5.09 |
Curveball |
23.08% |
3 |
1 |
2 |
33.33% |
66.67% |
72.21 |
1747.72 |
-0.26 |
-4.29 |
71.12 |
2.4 |
5.56 |
0.90 |
4.59 |
Four-Seam |
7.69% |
1 |
1 |
0 |
100.00% |
0.00% |
83.74 |
2197.85 |
21.41 |
9.25 |
204.93 |
6.8 |
5.67 |
0.93 |
5.23 |
NA |
7.69% |
1 |
1 |
0 |
100.00% |
0.00% |
72.60 |
1767.29 |
NaN |
NaN |
NaN |
NaN |
5.71 |
1.27 |
4.86 |
# 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("Yoon Chae maximum FB velocity: ", max_fb_velocity, "mph\n")
## Yoon Chae maximum FB velocity: 83.74 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 Yoon Chae",
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")
)
