DaveM2430 commited on
Commit
125b3a3
·
verified ·
1 Parent(s): 44d99e4

Update app.R

Browse files
Files changed (1) hide show
  1. app.R +3 -3
app.R CHANGED
@@ -34,7 +34,7 @@ build_pitcher_stats <- function(df, min_pitches) {
34
  IsPA = (!is.na(KorBB) & KorBB %in% c("Strikeout","Walk")) |
35
  (!is.na(PitchCall) & PitchCall %in% c("InPlay","HitByPitch"))
36
  ) %>%
37
- group_by(Pitcher, Level, PitcherTeam) %>%
38
  summarise(
39
  Pitches = n(),
40
  K = sum(IsK, na.rm=TRUE),
@@ -64,10 +64,10 @@ build_pitcher_stats <- function(df, min_pitches) {
64
  na.rm=TRUE),
65
  .groups = "drop"
66
  ) %>%
67
- ungroup() %>%
68
  filter(Pitches >= min_pitches) %>%
69
  mutate(
70
  Name = sapply(Pitcher, format_name),
 
71
  `Zone%` = round(zone_n / Pitches * 100, 1),
72
  `Strike%` = round(strike_n / Pitches * 100, 1),
73
  `K's` = K,
@@ -90,7 +90,7 @@ build_pitcher_stats <- function(df, min_pitches) {
90
  # must have both first and last name (at least one space)
91
  grepl(" ", trimws(Name))
92
  ) %>%
93
- select(Name, Level, Team=PitcherTeam, Pitches, `FB Velo`, `Zone%`, `Strike%`,
94
  `K's`, `BB's`, `K/BB`, `Whiff%`, `Chase%`, `Hard Hit%`) %>%
95
  arrange(desc(Pitches))
96
  }
 
34
  IsPA = (!is.na(KorBB) & KorBB %in% c("Strikeout","Walk")) |
35
  (!is.na(PitchCall) & PitchCall %in% c("InPlay","HitByPitch"))
36
  ) %>%
37
+ group_by(Pitcher, Level) %>%
38
  summarise(
39
  Pitches = n(),
40
  K = sum(IsK, na.rm=TRUE),
 
64
  na.rm=TRUE),
65
  .groups = "drop"
66
  ) %>%
 
67
  filter(Pitches >= min_pitches) %>%
68
  mutate(
69
  Name = sapply(Pitcher, format_name),
70
+ Team = first(PitcherTeam),
71
  `Zone%` = round(zone_n / Pitches * 100, 1),
72
  `Strike%` = round(strike_n / Pitches * 100, 1),
73
  `K's` = K,
 
90
  # must have both first and last name (at least one space)
91
  grepl(" ", trimws(Name))
92
  ) %>%
93
+ select(Name, Level, Team, Pitches, `FB Velo`, `Zone%`, `Strike%`,
94
  `K's`, `BB's`, `K/BB`, `Whiff%`, `Chase%`, `Hard Hit%`) %>%
95
  arrange(desc(Pitches))
96
  }