# Filter the data for the pitcher Nick Falter
Brian_Foley_data <- data %>%
filter(Pitcher == "Falter, Nick")
# 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 Nick Falter")
Detailed Pitch Table for Nick Falter
Four-Seam |
91.66 |
2432.07 |
224.48 |
14.25 |
15.76 |
HitByPitch |
5.21 |
1.67 |
6.08 |
7.5 |
Sinker |
91.65 |
2374.08 |
236.70 |
15.71 |
11.46 |
InPlay |
5.33 |
1.87 |
6.20 |
7.9 |
Sinker |
91.53 |
2358.95 |
243.10 |
17.03 |
9.78 |
StrikeCalled |
5.29 |
1.60 |
6.15 |
8.1 |
Changeup |
85.36 |
1592.59 |
277.65 |
14.04 |
-0.57 |
BallCalled |
5.35 |
1.72 |
5.68 |
9.3 |
Four-Seam |
90.88 |
2512.46 |
218.45 |
8.03 |
11.25 |
FoulBallNotFieldable |
5.25 |
1.77 |
5.94 |
7.3 |
Slider |
86.91 |
2445.40 |
202.30 |
1.77 |
5.48 |
StrikeCalled |
5.29 |
1.66 |
5.59 |
6.7 |
Four-Seam |
93.17 |
2501.65 |
218.40 |
11.28 |
15.34 |
FoulBallNotFieldable |
5.28 |
1.59 |
5.99 |
7.3 |
Slider |
80.63 |
2273.44 |
161.94 |
-1.19 |
5.00 |
FoulBallNotFieldable |
5.40 |
1.57 |
5.62 |
5.4 |
Four-Seam |
93.45 |
2468.20 |
225.31 |
11.70 |
12.59 |
BallCalled |
5.23 |
1.54 |
6.20 |
7.5 |
Slider |
84.24 |
2291.34 |
169.54 |
-0.74 |
5.15 |
StrikeSwinging |
5.43 |
1.46 |
5.72 |
5.7 |
# 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: 10
# Display the summary table
knitr::kable(pitch_summary, caption = "Summary Pitch Table for Nick Falter")
Summary Pitch Table for Nick Falter
Changeup |
10.00% |
1 |
1 |
0 |
100.00% |
0.00% |
85.36 |
1592.59 |
-0.57 |
14.04 |
277.65 |
9.3 |
5.35 |
1.72 |
5.68 |
Four-Seam |
40.00% |
4 |
1 |
3 |
25.00% |
75.00% |
92.29 |
2478.60 |
13.73 |
11.31 |
221.66 |
7.4 |
5.24 |
1.64 |
6.05 |
Sinker |
20.00% |
2 |
0 |
2 |
0.00% |
100.00% |
91.59 |
2366.51 |
10.62 |
16.37 |
239.90 |
8.0 |
5.31 |
1.74 |
6.18 |
Slider |
30.00% |
3 |
0 |
3 |
0.00% |
100.00% |
83.93 |
2336.73 |
5.21 |
-0.05 |
177.93 |
5.9 |
5.37 |
1.56 |
5.64 |
# 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("Nick Falter maximum FB velocity: ", max_fb_velocity, "mph\n")
## Nick Falter maximum FB velocity: 93.45 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 Nick Falter",
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")
)
