igroffman commited on
Commit
38a4a20
·
verified ·
1 Parent(s): 71bd9c7

Update app.R

Browse files
Files changed (1) hide show
  1. app.R +11 -12
app.R CHANGED
@@ -2533,23 +2533,22 @@ create_advanced_pitcher_summary <- function(data, player_name) {
2533
 
2534
  summary_stats <- pitcher_data %>%
2535
  dplyr::summarise(
2536
- {
2537
  total_outs <- sum(OutsOnPlay, na.rm = TRUE)
2538
  full_innings <- floor(total_outs / 3)
2539
  remainder_outs <- total_outs %% 3
2540
- IP_display <- full_innings + remainder_outs / 10
2541
- IP_display
2542
- } -> IP,
2543
- R = sum(RunsScored, na.rm = TRUE),
2544
  BF = n_distinct(paste(Inning, Batter, PAofInning)),
2545
- K = sum(KorBB == "Strikeout", na.rm = TRUE),
2546
  BB = sum(WalkIndicator, na.rm = TRUE),
2547
- H = sum(PlayResult %in% c("Single", "Double", "Triple", "HomeRun"), na.rm = TRUE),
2548
- `Strike%` = round(100 * mean(is_csw | PitchCall %in% c("FoulBall", "FoulBallNotFieldable", "InPlay"), na.rm = TRUE), 1),
2549
- `CSW%` = round(100 * mean(is_csw, na.rm = TRUE), 1),
2550
- `Whiff%` = ifelse(sum(SwingIndicator, na.rm = TRUE) > 0,
2551
- round(100 * sum(is_whiff, na.rm = TRUE) / sum(SwingIndicator, na.rm = TRUE), 1), 0),
2552
- `Zone%` = round(100 * mean(in_zone, na.rm = TRUE), 1),
2553
  .groups = "drop"
2554
  )
2555
 
 
2533
 
2534
  summary_stats <- pitcher_data %>%
2535
  dplyr::summarise(
2536
+ IP = {
2537
  total_outs <- sum(OutsOnPlay, na.rm = TRUE)
2538
  full_innings <- floor(total_outs / 3)
2539
  remainder_outs <- total_outs %% 3
2540
+ full_innings + remainder_outs / 10
2541
+ },
2542
+ R = sum(RunsScored, na.rm = TRUE),
 
2543
  BF = n_distinct(paste(Inning, Batter, PAofInning)),
2544
+ K = sum(KorBB == "Strikeout", na.rm = TRUE),
2545
  BB = sum(WalkIndicator, na.rm = TRUE),
2546
+ H = sum(PlayResult %in% c("Single","Double","Triple","HomeRun"), na.rm = TRUE),
2547
+ `Strike%` = round(100 * mean(is_csw | PitchCall %in% c("FoulBall","FoulBallNotFieldable","InPlay"), na.rm = TRUE), 1),
2548
+ `CSW%` = round(100 * mean(is_csw, na.rm = TRUE), 1),
2549
+ `Whiff%` = ifelse(sum(SwingIndicator, na.rm = TRUE) > 0,
2550
+ round(100 * sum(is_whiff, na.rm = TRUE) / sum(SwingIndicator, na.rm = TRUE), 1), 0),
2551
+ `Zone%` = round(100 * mean(in_zone, na.rm = TRUE), 1),
2552
  .groups = "drop"
2553
  )
2554