igroffman commited on
Commit
17a1068
·
verified ·
1 Parent(s): de9bbd0

Update app.R

Browse files
Files changed (1) hide show
  1. app.R +5 -4
app.R CHANGED
@@ -2237,14 +2237,15 @@ catcher_create_catcher_pdf <- function(game_df, catcher_name, output_file, bio_d
2237
  `CCU Game +/-` = sum(StolenStrike, na.rm = TRUE) - sum(StrikeLost, na.rm = TRUE),
2238
  .groups = "drop")
2239
 
2240
- ccu_pitcher_team <- game_df %>%
2241
- filter(Catcher == catcher_name) %>%
2242
- pull(PitcherTeam) %>%
 
2243
  na.omit() %>%
2244
  { names(sort(table(.), decreasing=TRUE))[1] }
2245
 
2246
  opp_receiving_stats <- catcher_df %>%
2247
- filter(PitcherTeam == ccu_pitcher_team) %>% # CCU pitching = opponent batting
2248
  summarise(
2249
  `Opp Strikes Stolen` = sum(StolenStrike, na.rm = TRUE),
2250
  `Opp Strikes Lost` = sum(StrikeLost, na.rm = TRUE),
 
2237
  `CCU Game +/-` = sum(StolenStrike, na.rm = TRUE) - sum(StrikeLost, na.rm = TRUE),
2238
  .groups = "drop")
2239
 
2240
+ # Dynamically find the opponent BatterTeam ID (not CCU)
2241
+ opp_batter_team_id <- game_df %>%
2242
+ filter(PitcherTeam == "COA_CHA") %>%
2243
+ pull(BatterTeam) %>%
2244
  na.omit() %>%
2245
  { names(sort(table(.), decreasing=TRUE))[1] }
2246
 
2247
  opp_receiving_stats <- catcher_df %>%
2248
+ filter(BatterTeam == opp_batter_team_id) %>%
2249
  summarise(
2250
  `Opp Strikes Stolen` = sum(StolenStrike, na.rm = TRUE),
2251
  `Opp Strikes Lost` = sum(StrikeLost, na.rm = TRUE),