Update app.R
Browse files
app.R
CHANGED
|
@@ -118,14 +118,15 @@ pitcher_summary <- function(tmilb){
|
|
| 118 |
tmilb %>%
|
| 119 |
select(Batter,Pitcher,PlayResult,PitchCall,TaggedPitchType,RelSpeed,SpinRate,
|
| 120 |
Extension,PlateLocSide,PlateLocHeight,RelSide,RelHeight,ax0,ay0,az0,vx0,
|
| 121 |
-
vz0,vy0,pfxx,pfxz,InducedVertBreak,HorzBreak,SpinAxis,PitcherThrows,BatterSide,PitchofPA,VertApprAngle) %>%
|
| 122 |
rename(
|
| 123 |
"Batter Name" = Batter, "Pitcher Name" = Pitcher, result = PlayResult,
|
| 124 |
description = PitchCall, pitch_name = TaggedPitchType, start_speed = RelSpeed,
|
| 125 |
spin_rate = SpinRate, extension = Extension, px = PlateLocSide, pz = PlateLocHeight,
|
| 126 |
x0 = RelSide, z0 = RelHeight, ax = ax0, ay = ay0, az = az0, vx0 = vx0,
|
| 127 |
vz0 = vz0, vy0 = vy0, pfxX = pfxx, pfxZ = pfxz, IVB = InducedVertBreak,
|
| 128 |
-
HB = HorzBreak, spinDirection = SpinAxis, phand = PitcherThrows,
|
|
|
|
| 129 |
) %>%
|
| 130 |
mutate(
|
| 131 |
is_strike_swinging = ifelse(description == "StrikeSwinging", TRUE, FALSE),
|
|
@@ -142,6 +143,7 @@ break_plot <- function(game){
|
|
| 142 |
pitch_name %in% c("ChangeUp") ~ "Changeup",
|
| 143 |
pitch_name %in% c("KnuckleCurve") ~ "Knuckle Curve",
|
| 144 |
pitch_name %in% c("CutFastBall") ~ "Cutter",
|
|
|
|
| 145 |
TRUE ~ pitch_name
|
| 146 |
))
|
| 147 |
pitch_colors <- c(
|
|
@@ -177,6 +179,7 @@ pitch_plot <- function(game, title) {
|
|
| 177 |
pitch_name %in% c("ChangeUp") ~ "Changeup",
|
| 178 |
pitch_name %in% c("KnuckleCurve") ~ "Knuckle Curve",
|
| 179 |
pitch_name %in% c("CutFastBall") ~ "Cutter",
|
|
|
|
| 180 |
TRUE ~ pitch_name
|
| 181 |
))
|
| 182 |
pitch_colors <- c(
|
|
@@ -216,6 +219,7 @@ pitch_plot_split <- function(game, title) {
|
|
| 216 |
pitch_name %in% c("ChangeUp") ~ "Changeup",
|
| 217 |
pitch_name %in% c("KnuckleCurve") ~ "Knuckle Curve",
|
| 218 |
pitch_name %in% c("CutFastBall") ~ "Cutter",
|
|
|
|
| 219 |
TRUE ~ pitch_name
|
| 220 |
))
|
| 221 |
game_rhb <- game %>% filter(bhand == "R") %>% mutate(
|
|
@@ -225,6 +229,7 @@ pitch_plot_split <- function(game, title) {
|
|
| 225 |
pitch_name %in% c("ChangeUp") ~ "Changeup",
|
| 226 |
pitch_name %in% c("KnuckleCurve") ~ "Knuckle Curve",
|
| 227 |
pitch_name %in% c("CutFastBall") ~ "Cutter",
|
|
|
|
| 228 |
TRUE ~ pitch_name
|
| 229 |
))
|
| 230 |
|
|
@@ -498,6 +503,7 @@ summary_table <- function(game) {
|
|
| 498 |
pitch_name %in% c("ChangeUp") ~ "Changeup",
|
| 499 |
pitch_name %in% c("KnuckleCurve") ~ "Knuckle Curve",
|
| 500 |
pitch_name %in% c("CutFastBall") ~ "Cutter",
|
|
|
|
| 501 |
TRUE ~ pitch_name
|
| 502 |
),
|
| 503 |
Pitch = pitch_name,
|
|
@@ -827,6 +833,7 @@ server <- function(input, output, session) {
|
|
| 827 |
pitch_name %in% c("ChangeUp") ~ "Changeup",
|
| 828 |
pitch_name %in% c("KnuckleCurve") ~ "Knuckle Curve",
|
| 829 |
pitch_name %in% c("CutFastBall") ~ "Cutter",
|
|
|
|
| 830 |
TRUE ~ pitch_name
|
| 831 |
))
|
| 832 |
timstuff_plot <- ggplot(rolling_data, aes(x = pitch_number, y = rolling_timstuff, color = pitch_name)) +
|
|
|
|
| 118 |
tmilb %>%
|
| 119 |
select(Batter,Pitcher,PlayResult,PitchCall,TaggedPitchType,RelSpeed,SpinRate,
|
| 120 |
Extension,PlateLocSide,PlateLocHeight,RelSide,RelHeight,ax0,ay0,az0,vx0,
|
| 121 |
+
vz0,vy0,pfxx,pfxz,InducedVertBreak,HorzBreak,SpinAxis,PitcherThrows,BatterSide,PitchofPA,VertApprAngle,AutoPitchType) %>%
|
| 122 |
rename(
|
| 123 |
"Batter Name" = Batter, "Pitcher Name" = Pitcher, result = PlayResult,
|
| 124 |
description = PitchCall, pitch_name = TaggedPitchType, start_speed = RelSpeed,
|
| 125 |
spin_rate = SpinRate, extension = Extension, px = PlateLocSide, pz = PlateLocHeight,
|
| 126 |
x0 = RelSide, z0 = RelHeight, ax = ax0, ay = ay0, az = az0, vx0 = vx0,
|
| 127 |
vz0 = vz0, vy0 = vy0, pfxX = pfxx, pfxZ = pfxz, IVB = InducedVertBreak,
|
| 128 |
+
HB = HorzBreak, spinDirection = SpinAxis, phand = PitcherThrows,
|
| 129 |
+
bhand = BatterSide, PitchNum = PitchofPA, VAA = VertApprAngle, AutoPitchType = AutoPitchType
|
| 130 |
) %>%
|
| 131 |
mutate(
|
| 132 |
is_strike_swinging = ifelse(description == "StrikeSwinging", TRUE, FALSE),
|
|
|
|
| 143 |
pitch_name %in% c("ChangeUp") ~ "Changeup",
|
| 144 |
pitch_name %in% c("KnuckleCurve") ~ "Knuckle Curve",
|
| 145 |
pitch_name %in% c("CutFastBall") ~ "Cutter",
|
| 146 |
+
pitch_name %in% c('Undefined') ~ AutoPitchType,
|
| 147 |
TRUE ~ pitch_name
|
| 148 |
))
|
| 149 |
pitch_colors <- c(
|
|
|
|
| 179 |
pitch_name %in% c("ChangeUp") ~ "Changeup",
|
| 180 |
pitch_name %in% c("KnuckleCurve") ~ "Knuckle Curve",
|
| 181 |
pitch_name %in% c("CutFastBall") ~ "Cutter",
|
| 182 |
+
pitch_name %in% c('Undefined') ~ AutoPitchType,
|
| 183 |
TRUE ~ pitch_name
|
| 184 |
))
|
| 185 |
pitch_colors <- c(
|
|
|
|
| 219 |
pitch_name %in% c("ChangeUp") ~ "Changeup",
|
| 220 |
pitch_name %in% c("KnuckleCurve") ~ "Knuckle Curve",
|
| 221 |
pitch_name %in% c("CutFastBall") ~ "Cutter",
|
| 222 |
+
pitch_name %in% c('Undefined') ~ AutoPitchType,
|
| 223 |
TRUE ~ pitch_name
|
| 224 |
))
|
| 225 |
game_rhb <- game %>% filter(bhand == "R") %>% mutate(
|
|
|
|
| 229 |
pitch_name %in% c("ChangeUp") ~ "Changeup",
|
| 230 |
pitch_name %in% c("KnuckleCurve") ~ "Knuckle Curve",
|
| 231 |
pitch_name %in% c("CutFastBall") ~ "Cutter",
|
| 232 |
+
pitch_name %in% c('Undefined') ~ AutoPitchType,
|
| 233 |
TRUE ~ pitch_name
|
| 234 |
))
|
| 235 |
|
|
|
|
| 503 |
pitch_name %in% c("ChangeUp") ~ "Changeup",
|
| 504 |
pitch_name %in% c("KnuckleCurve") ~ "Knuckle Curve",
|
| 505 |
pitch_name %in% c("CutFastBall") ~ "Cutter",
|
| 506 |
+
pitch_name %in% c('Undefined') ~ AutoPitchType,
|
| 507 |
TRUE ~ pitch_name
|
| 508 |
),
|
| 509 |
Pitch = pitch_name,
|
|
|
|
| 833 |
pitch_name %in% c("ChangeUp") ~ "Changeup",
|
| 834 |
pitch_name %in% c("KnuckleCurve") ~ "Knuckle Curve",
|
| 835 |
pitch_name %in% c("CutFastBall") ~ "Cutter",
|
| 836 |
+
pitch_name %in% c('Undefined') ~ AutoPitchType,
|
| 837 |
TRUE ~ pitch_name
|
| 838 |
))
|
| 839 |
timstuff_plot <- ggplot(rolling_data, aes(x = pitch_number, y = rolling_timstuff, color = pitch_name)) +
|