# Filter the data for the pitcher Colin Burke
Brian_Foley_data <- data %>%
filter(Pitcher == "Burke, Colin")
# 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 Colin Burke")
Detailed Pitch Table for Colin Burke
Four-Seam |
87.05 |
2017.29 |
210.51 |
11.30 |
20.54 |
BallCalled |
6.68 |
0.60 |
4.82 |
7.0 |
Four-Seam |
86.44 |
2002.16 |
211.89 |
11.48 |
19.76 |
BallCalled |
6.61 |
0.69 |
4.79 |
7.1 |
Four-Seam |
85.97 |
2025.54 |
211.48 |
11.84 |
20.68 |
InPlay |
6.58 |
0.54 |
4.75 |
7.0 |
Curveball |
79.18 |
2418.32 |
18.72 |
-5.76 |
-15.39 |
BallCalled |
6.54 |
0.67 |
4.39 |
0.6 |
Four-Seam |
87.06 |
1970.44 |
210.80 |
11.30 |
20.24 |
BallCalled |
6.63 |
0.73 |
4.75 |
7.0 |
Changeup |
87.09 |
1924.62 |
216.39 |
12.07 |
17.66 |
FoulBallNotFieldable |
6.56 |
0.61 |
4.73 |
7.2 |
Changeup |
79.36 |
1645.93 |
177.47 |
-0.25 |
7.15 |
BallCalled |
6.35 |
0.89 |
4.32 |
5.9 |
Four-Seam |
87.58 |
2106.29 |
204.68 |
9.98 |
23.01 |
StrikeCalled |
6.59 |
0.59 |
4.69 |
6.8 |
Four-Seam |
86.56 |
2119.50 |
205.90 |
10.87 |
23.74 |
FoulBallNotFieldable |
6.61 |
0.51 |
4.69 |
6.9 |
Slider |
80.18 |
1774.59 |
180.76 |
0.07 |
6.88 |
BallCalled |
6.39 |
0.84 |
4.31 |
6.0 |
Changeup |
85.82 |
2010.54 |
224.47 |
13.74 |
15.36 |
InPlay |
6.56 |
0.79 |
4.57 |
7.5 |
Four-Seam |
86.60 |
2036.02 |
210.74 |
10.50 |
18.96 |
InPlay |
6.68 |
0.69 |
4.87 |
7.0 |
Changeup |
78.06 |
1637.72 |
165.74 |
-1.40 |
7.27 |
BallCalled |
6.35 |
0.92 |
4.08 |
5.5 |
Four-Seam |
86.36 |
2162.69 |
212.53 |
12.69 |
21.22 |
InPlay |
6.54 |
0.63 |
4.61 |
7.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: 14
# Display the summary table
knitr::kable(pitch_summary, caption = "Summary Pitch Table for Colin Burke")
Summary Pitch Table for Colin Burke
Changeup |
28.57% |
4 |
2 |
2 |
50.00% |
50.00% |
82.58 |
1804.70 |
11.86 |
6.04 |
196.02 |
6.5 |
6.46 |
0.80 |
4.43 |
Curveball |
7.14% |
1 |
1 |
0 |
100.00% |
0.00% |
79.18 |
2418.32 |
-15.39 |
-5.76 |
18.72 |
0.6 |
6.54 |
0.67 |
4.39 |
Four-Seam |
57.14% |
8 |
3 |
5 |
37.50% |
62.50% |
86.70 |
2054.99 |
21.02 |
11.25 |
209.82 |
7.0 |
6.62 |
0.62 |
4.75 |
Slider |
7.14% |
1 |
1 |
0 |
100.00% |
0.00% |
80.18 |
1774.59 |
6.88 |
0.07 |
180.76 |
6.0 |
6.39 |
0.84 |
4.31 |
# 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("Colin Burke maximum FB velocity: ", max_fb_velocity, "mph\n")
## Colin Burke maximum FB velocity: 87.58 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 Colin Burke",
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")
)
