# 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.36 |
2085.32 |
239.68 |
14.64 |
9.83 |
StrikeCalled |
5.13 |
1.78 |
5.64 |
8.0 |
Curveball |
74.02 |
2914.07 |
49.68 |
-18.18 |
-13.52 |
InPlay |
5.26 |
1.89 |
5.09 |
1.7 |
Curveball |
74.08 |
2851.07 |
63.86 |
-22.53 |
-9.05 |
BallCalled |
5.29 |
1.89 |
4.90 |
2.1 |
Changeup |
86.87 |
2098.50 |
217.58 |
11.10 |
15.69 |
FoulBallNotFieldable |
5.22 |
1.86 |
5.59 |
7.3 |
Curveball |
74.53 |
2988.26 |
58.59 |
-17.93 |
-9.15 |
BallCalled |
5.24 |
2.18 |
5.15 |
2.0 |
Four-Seam |
87.86 |
2151.82 |
216.52 |
10.26 |
15.06 |
InPlay |
5.15 |
2.15 |
5.85 |
7.2 |
Sinker |
86.85 |
2158.89 |
223.60 |
12.58 |
14.35 |
BallCalled |
5.32 |
1.92 |
5.83 |
7.5 |
Curveball |
75.08 |
2841.79 |
40.13 |
-14.90 |
-16.01 |
BallCalled |
5.18 |
2.09 |
5.41 |
1.3 |
Four-Seam |
87.57 |
2154.95 |
214.10 |
8.55 |
13.79 |
StrikeCalled |
5.22 |
1.94 |
5.79 |
7.1 |
Curveball |
74.73 |
2883.70 |
52.66 |
-14.52 |
-9.30 |
StrikeSwinging |
5.28 |
2.03 |
5.18 |
1.8 |
Curveball |
75.14 |
2979.40 |
55.12 |
-16.15 |
-9.55 |
StrikeSwinging |
5.24 |
1.97 |
5.26 |
1.8 |
Changeup |
87.06 |
2029.70 |
217.10 |
11.84 |
16.81 |
StrikeCalled |
5.27 |
1.91 |
5.56 |
7.2 |
Curveball |
74.53 |
2921.89 |
59.98 |
-18.85 |
-9.17 |
BallCalled |
5.26 |
2.10 |
5.15 |
2.0 |
Curveball |
75.15 |
2915.95 |
46.42 |
-15.14 |
-12.80 |
BallCalled |
5.17 |
1.99 |
5.43 |
1.5 |
Sinker |
87.52 |
2138.35 |
218.34 |
10.21 |
14.02 |
FoulBallNotFieldable |
5.18 |
1.90 |
5.86 |
7.3 |
Curveball |
74.42 |
2943.87 |
50.00 |
-18.31 |
-13.51 |
StrikeSwinging |
5.15 |
1.97 |
5.31 |
1.7 |
Curveball |
74.72 |
2971.82 |
38.44 |
-13.05 |
-14.69 |
StrikeCalled |
5.31 |
1.96 |
5.06 |
1.3 |
Curveball |
74.99 |
2948.60 |
40.46 |
-14.37 |
-14.98 |
BallCalled |
5.22 |
1.94 |
4.88 |
1.3 |
Changeup |
86.57 |
2087.24 |
219.12 |
10.40 |
14.00 |
BallCalled |
5.15 |
1.80 |
5.77 |
7.3 |
Curveball |
74.41 |
2988.25 |
38.42 |
-13.34 |
-14.99 |
BallCalled |
5.19 |
2.04 |
5.12 |
1.3 |
Four-Seam |
86.77 |
2129.33 |
213.20 |
8.27 |
13.83 |
BallCalled |
5.19 |
1.95 |
5.75 |
7.1 |
Four-Seam |
88.22 |
2155.82 |
215.79 |
8.37 |
12.80 |
StrikeCalled |
5.06 |
1.91 |
5.90 |
7.2 |
Curveball |
75.64 |
2947.68 |
44.49 |
-14.14 |
-12.68 |
BallCalled |
5.20 |
2.02 |
5.27 |
1.5 |
Four-Seam |
89.17 |
2181.81 |
213.20 |
9.15 |
15.08 |
StrikeSwinging |
5.19 |
1.64 |
7.25 |
7.1 |
Four-Seam |
89.43 |
2244.44 |
216.69 |
10.20 |
14.90 |
BallCalled |
5.33 |
1.76 |
5.82 |
7.2 |
Curveball |
74.26 |
2916.63 |
52.76 |
-20.04 |
-13.42 |
BallCalled |
4.93 |
2.13 |
5.51 |
1.8 |
Sinker |
88.76 |
2128.50 |
220.79 |
14.59 |
18.11 |
BallCalled |
5.22 |
1.88 |
5.88 |
7.4 |
Sinker |
87.43 |
2101.92 |
221.27 |
11.58 |
14.42 |
BallCalled |
5.06 |
1.95 |
5.89 |
7.4 |
Sinker |
87.67 |
2145.17 |
224.70 |
13.78 |
15.18 |
InPlay |
5.11 |
1.95 |
5.99 |
7.5 |
Four-Seam |
88.55 |
2212.77 |
211.11 |
7.61 |
13.79 |
StrikeCalled |
5.17 |
1.89 |
5.84 |
7.0 |
Curveball |
75.30 |
2998.67 |
48.22 |
-18.31 |
-14.55 |
BallCalled |
5.25 |
1.95 |
5.20 |
1.6 |
Curveball |
74.78 |
2826.88 |
51.93 |
-18.49 |
-12.71 |
StrikeCalled |
5.17 |
2.01 |
5.32 |
1.7 |
Four-Seam |
89.06 |
2291.76 |
217.00 |
10.41 |
14.96 |
BallCalled |
5.30 |
1.61 |
7.18 |
7.2 |
Curveball |
75.25 |
2926.57 |
47.30 |
-15.75 |
-12.80 |
BallCalled |
5.12 |
1.91 |
5.44 |
1.6 |
Sinker |
88.70 |
2153.24 |
222.30 |
11.21 |
13.49 |
FoulBallNotFieldable |
5.22 |
1.84 |
5.88 |
7.4 |
Four-Seam |
88.51 |
2166.91 |
221.15 |
11.55 |
14.27 |
FoulBallNotFieldable |
5.21 |
1.81 |
5.85 |
7.4 |
Curveball |
74.26 |
2975.62 |
49.39 |
-17.83 |
-13.36 |
BallCalled |
5.24 |
2.07 |
5.16 |
1.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 == "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: 37
# Display the summary table
knitr::kable(pitch_summary, caption = "Summary Pitch Table for Colin Dowlen")
Summary Pitch Table for Colin Dowlen
Changeup |
8.11% |
3 |
1 |
2 |
33.33% |
66.67% |
86.83 |
2071.81 |
15.50 |
11.11 |
217.93 |
7.3 |
5.21 |
1.86 |
5.64 |
Curveball |
48.65% |
18 |
12 |
6 |
66.67% |
33.33% |
74.74 |
2930.04 |
-12.57 |
-16.77 |
49.33 |
1.6 |
5.21 |
2.01 |
5.21 |
Four-Seam |
24.32% |
9 |
3 |
6 |
33.33% |
66.67% |
88.35 |
2187.73 |
14.28 |
9.37 |
215.42 |
7.2 |
5.20 |
1.85 |
6.14 |
Sinker |
18.92% |
7 |
3 |
4 |
42.86% |
57.14% |
87.76 |
2130.20 |
14.20 |
12.66 |
224.38 |
7.5 |
5.18 |
1.89 |
5.85 |
# 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("Colin Dowlen maximum FB velocity: ", max_fb_velocity, "mph\n")
## Colin Dowlen maximum FB velocity: 89.43 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 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")
)
