# 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
NA |
NA |
NA |
NA |
NA |
NA |
FoulBallNotFieldable |
NA |
NA |
NA |
NA |
Four-Seam |
87.37 |
1963.11 |
207.69 |
9.43 |
19.28 |
FoulBallNotFieldable |
6.72 |
0.42 |
4.98 |
6.9 |
Curveball |
79.07 |
2743.66 |
11.37 |
-4.39 |
-20.17 |
BallCalled |
6.64 |
0.33 |
4.43 |
0.4 |
Four-Seam |
85.72 |
2044.14 |
204.03 |
8.16 |
19.76 |
InPlay |
6.69 |
0.46 |
4.72 |
6.8 |
Four-Seam |
87.50 |
2088.72 |
208.13 |
10.91 |
21.92 |
StrikeCalled |
6.66 |
0.65 |
4.69 |
6.9 |
Curveball |
79.77 |
2710.17 |
20.71 |
-6.23 |
-14.87 |
BallCalled |
6.44 |
0.78 |
4.58 |
0.7 |
Curveball |
78.94 |
2535.84 |
17.49 |
-6.80 |
-19.90 |
StrikeCalled |
6.45 |
0.92 |
4.46 |
0.6 |
Curveball |
79.10 |
2632.94 |
16.17 |
-6.65 |
-21.25 |
BallCalled |
6.48 |
0.84 |
4.50 |
0.5 |
Curveball |
79.36 |
2600.94 |
8.12 |
-2.82 |
-18.12 |
InPlay |
6.47 |
0.78 |
4.63 |
0.3 |
Four-Seam |
88.33 |
2005.53 |
220.03 |
13.53 |
17.51 |
BallCalled |
6.72 |
0.65 |
5.09 |
7.3 |
Four-Seam |
87.86 |
2057.47 |
211.81 |
10.75 |
18.77 |
InPlay |
6.64 |
0.79 |
4.77 |
7.1 |
Four-Seam |
86.48 |
2134.60 |
200.01 |
7.31 |
21.62 |
BallCalled |
6.81 |
0.69 |
4.79 |
6.7 |
Curveball |
79.27 |
2626.74 |
7.75 |
-2.56 |
-17.18 |
StrikeCalled |
6.51 |
0.70 |
4.52 |
0.3 |
Four-Seam |
88.16 |
2007.05 |
210.09 |
11.21 |
20.78 |
FoulBallNotFieldable |
6.78 |
0.71 |
4.89 |
7.0 |
Four-Seam |
87.94 |
1972.22 |
212.75 |
12.07 |
20.22 |
FoulBallNotFieldable |
6.72 |
0.64 |
4.81 |
7.1 |
Curveball |
77.71 |
2468.20 |
6.52 |
-2.46 |
-19.78 |
BallCalled |
6.58 |
1.01 |
4.47 |
0.2 |
Four-Seam |
88.32 |
2076.21 |
212.83 |
12.94 |
21.52 |
BallCalled |
6.77 |
0.74 |
4.83 |
7.1 |
Curveball |
78.50 |
2535.84 |
359.39 |
0.25 |
-21.75 |
StrikeSwinging |
6.50 |
0.81 |
4.66 |
12.0 |
Four-Seam |
87.91 |
1972.98 |
208.14 |
10.40 |
20.83 |
BallCalled |
6.73 |
0.61 |
4.83 |
6.9 |
Curveball |
79.40 |
2609.78 |
33.47 |
-10.93 |
-14.85 |
BallCalled |
6.52 |
0.73 |
4.41 |
1.1 |
Sinker |
87.19 |
1991.99 |
220.78 |
13.72 |
17.35 |
BallCalled |
6.72 |
0.70 |
4.93 |
7.4 |
Changeup |
80.38 |
1637.36 |
190.59 |
1.08 |
7.35 |
StrikeCalled |
6.36 |
1.01 |
4.53 |
6.4 |
Changeup |
78.71 |
1643.41 |
209.96 |
3.42 |
7.63 |
StrikeCalled |
6.39 |
0.90 |
4.69 |
7.0 |
Curveball |
80.31 |
2624.04 |
30.58 |
-8.68 |
-13.08 |
InPlay |
6.43 |
0.75 |
4.43 |
1.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 %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: 24
# Display the summary table
knitr::kable(pitch_summary, caption = "Summary Pitch Table for Colin Burke")
Summary Pitch Table for Colin Burke
Changeup |
8.33% |
2 |
0 |
2 |
0.00% |
100.00% |
79.54 |
1640.38 |
7.49 |
2.25 |
200.28 |
6.7 |
6.38 |
0.96 |
4.61 |
Curveball |
41.67% |
10 |
5 |
5 |
50.00% |
50.00% |
79.14 |
2608.82 |
-18.09 |
-5.13 |
51.16 |
1.7 |
6.50 |
0.76 |
4.51 |
Four-Seam |
41.67% |
10 |
4 |
6 |
40.00% |
60.00% |
87.56 |
2032.20 |
20.22 |
10.67 |
209.55 |
7.0 |
6.72 |
0.64 |
4.84 |
Sinker |
4.17% |
1 |
1 |
0 |
100.00% |
0.00% |
87.19 |
1991.99 |
17.35 |
13.72 |
220.78 |
7.4 |
6.72 |
0.70 |
4.93 |
NA |
4.17% |
1 |
0 |
1 |
0.00% |
100.00% |
NaN |
NaN |
NaN |
NaN |
NaN |
NaN |
NaN |
NaN |
NaN |
# 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: 88.33 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")
)
