# Filter the data for the pitcher Colin Dowlen
Brian_Foley_data <- data %>%
filter(Pitcher == "Dowlen, 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 Dowlen")
Detailed Pitch Table for Colin Dowlen
Sinker |
87.41 |
2087.22 |
226.41 |
14.65 |
15.18 |
StrikeCalled |
4.99 |
2.22 |
5.93 |
7.5 |
Curveball |
74.76 |
2904.98 |
52.22 |
-17.82 |
-12.12 |
FoulBallNotFieldable |
5.05 |
2.21 |
5.28 |
1.7 |
Sinker |
88.24 |
2118.66 |
223.95 |
12.78 |
14.55 |
FoulBallNotFieldable |
5.09 |
2.06 |
5.92 |
7.5 |
Curveball |
75.22 |
2933.92 |
45.55 |
-16.81 |
-14.75 |
FoulBallNotFieldable |
5.16 |
2.15 |
5.31 |
1.5 |
Changeup |
81.35 |
1462.69 |
234.04 |
9.38 |
8.20 |
BallCalled |
5.08 |
2.01 |
6.39 |
7.8 |
Curveball |
73.40 |
2867.62 |
60.14 |
-21.77 |
-10.50 |
InPlay |
5.19 |
2.23 |
4.94 |
2.0 |
Sinker |
86.91 |
2024.62 |
222.48 |
11.35 |
13.75 |
BallCalled |
5.04 |
2.12 |
5.87 |
7.4 |
Curveball |
73.71 |
2839.11 |
51.95 |
-16.66 |
-11.14 |
StrikeCalled |
5.14 |
2.17 |
5.27 |
1.7 |
Curveball |
74.37 |
2901.65 |
50.58 |
-17.45 |
-12.46 |
BallCalled |
5.19 |
2.18 |
5.37 |
1.7 |
Sinker |
87.26 |
2054.73 |
223.65 |
10.56 |
12.38 |
InPlay |
5.06 |
2.06 |
5.88 |
7.5 |
Curveball |
74.14 |
2929.93 |
52.80 |
-18.30 |
-12.02 |
StrikeCalled |
5.34 |
1.98 |
5.09 |
1.8 |
Curveball |
73.30 |
2905.07 |
52.43 |
-20.01 |
-13.39 |
StrikeCalled |
5.23 |
2.13 |
4.80 |
1.7 |
Four-Seam |
87.84 |
2073.61 |
215.47 |
10.34 |
15.74 |
FoulBallNotFieldable |
5.26 |
1.99 |
5.87 |
7.2 |
Curveball |
74.02 |
2868.86 |
61.05 |
-19.51 |
-9.03 |
InPlay |
4.94 |
2.26 |
5.46 |
2.0 |
Changeup |
86.13 |
2078.99 |
216.30 |
11.49 |
16.90 |
StrikeCalled |
5.18 |
2.16 |
5.63 |
7.2 |
Curveball |
73.30 |
2854.30 |
64.41 |
-19.02 |
-7.26 |
FoulBallNotFieldable |
5.30 |
2.08 |
5.17 |
2.1 |
Curveball |
74.12 |
2896.46 |
49.68 |
-15.25 |
-11.18 |
InPlay |
5.28 |
2.14 |
5.04 |
1.7 |
Curveball |
73.23 |
2763.85 |
56.52 |
-15.55 |
-8.47 |
BallCalled |
5.37 |
2.07 |
5.13 |
1.9 |
Curveball |
73.10 |
2875.28 |
51.79 |
-19.23 |
-13.21 |
StrikeCalled |
5.34 |
2.09 |
4.80 |
1.7 |
Sinker |
87.04 |
2133.03 |
225.25 |
13.95 |
15.05 |
StrikeCalled |
5.17 |
2.03 |
5.65 |
7.5 |
Curveball |
73.11 |
2867.37 |
55.40 |
-16.23 |
-9.31 |
BallCalled |
5.32 |
2.05 |
5.07 |
1.8 |
Curveball |
73.23 |
2887.76 |
75.12 |
-18.32 |
-3.12 |
BallCalled |
4.97 |
2.32 |
5.40 |
2.5 |
Sinker |
87.62 |
2120.47 |
223.22 |
10.78 |
12.69 |
InPlay |
5.20 |
1.85 |
5.77 |
7.4 |
Sinker |
87.52 |
2165.62 |
231.98 |
16.82 |
14.38 |
StrikeCalled |
5.12 |
2.02 |
5.71 |
7.7 |
Curveball |
72.86 |
2923.20 |
59.60 |
-20.31 |
-10.01 |
StrikeSwinging |
5.18 |
2.15 |
5.25 |
2.0 |
Curveball |
74.54 |
2837.02 |
50.29 |
-17.79 |
-13.06 |
FoulBallNotFieldable |
5.18 |
2.11 |
5.23 |
1.7 |
Four-Seam |
85.96 |
2168.04 |
208.00 |
7.91 |
16.29 |
InPlay |
5.22 |
2.17 |
5.76 |
6.9 |
Changeup |
86.02 |
2157.01 |
218.28 |
10.94 |
15.23 |
FoulBallNotFieldable |
5.28 |
1.92 |
5.71 |
7.3 |
Curveball |
72.85 |
2854.20 |
50.60 |
-18.31 |
-13.08 |
BallCalled |
5.22 |
2.02 |
5.25 |
1.7 |
Curveball |
72.75 |
2821.05 |
45.84 |
-14.84 |
-12.52 |
BallCalled |
5.30 |
2.20 |
5.32 |
1.5 |
Changeup |
85.75 |
2144.01 |
219.47 |
10.15 |
13.62 |
StrikeCalled |
5.23 |
2.08 |
5.82 |
7.3 |
Curveball |
73.47 |
2873.25 |
48.69 |
-17.72 |
-13.67 |
StrikeSwinging |
5.33 |
2.06 |
5.23 |
1.6 |
Changeup |
86.62 |
2072.84 |
220.36 |
12.16 |
15.58 |
BallCalled |
5.20 |
2.00 |
5.84 |
7.3 |
Curveball |
73.34 |
2883.45 |
52.86 |
-18.66 |
-12.15 |
StrikeCalled |
5.33 |
1.94 |
5.04 |
1.8 |
Curveball |
72.42 |
2743.09 |
54.49 |
-19.70 |
-12.11 |
BallCalled |
5.30 |
2.13 |
5.50 |
1.8 |
Changeup |
86.43 |
2071.76 |
218.81 |
10.34 |
14.11 |
FoulBallNotFieldable |
5.17 |
2.00 |
6.02 |
7.3 |
Curveball |
74.44 |
2787.77 |
50.10 |
-16.43 |
-11.90 |
FoulBallNotFieldable |
5.35 |
1.99 |
5.58 |
1.7 |
Curveball |
73.88 |
2852.01 |
61.29 |
-18.25 |
-8.28 |
StrikeSwinging |
4.93 |
2.29 |
5.46 |
2.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: 38
# Display the summary table
knitr::kable(pitch_summary, caption = "Summary Pitch Table for Colin Dowlen")
Summary Pitch Table for Colin Dowlen
Changeup |
15.79% |
6 |
2 |
4 |
33.33% |
66.67% |
85.38 |
1997.88 |
13.94 |
10.74 |
221.21 |
7.4 |
5.19 |
2.03 |
5.90 |
Curveball |
60.53% |
23 |
7 |
16 |
30.43% |
69.57% |
73.63 |
2863.97 |
-11.08 |
-18.00 |
54.50 |
1.8 |
5.21 |
2.13 |
5.22 |
Four-Seam |
5.26% |
2 |
0 |
2 |
0.00% |
100.00% |
86.90 |
2120.82 |
16.02 |
9.12 |
211.74 |
7.1 |
5.24 |
2.08 |
5.81 |
Sinker |
18.42% |
7 |
1 |
6 |
14.29% |
85.71% |
87.43 |
2100.62 |
14.00 |
12.98 |
225.28 |
7.5 |
5.10 |
2.05 |
5.82 |
# 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 Dowlen maximum FB velocity: ", max_fb_velocity, "mph\n")
## Colin Dowlen maximum FB velocity: 88.24 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 Dowlen",
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")
)
