Spaces:
Running
Running
Update app.R
Browse files
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 |
-
|
| 2541 |
-
|
| 2542 |
-
|
| 2543 |
-
R = sum(RunsScored, na.rm = TRUE),
|
| 2544 |
BF = n_distinct(paste(Inning, Batter, PAofInning)),
|
| 2545 |
-
K
|
| 2546 |
BB = sum(WalkIndicator, na.rm = TRUE),
|
| 2547 |
-
H
|
| 2548 |
-
`Strike%` = round(100 * mean(is_csw | PitchCall %in% c("FoulBall",
|
| 2549 |
-
`CSW%`
|
| 2550 |
-
`Whiff%`
|
| 2551 |
-
|
| 2552 |
-
`Zone%`
|
| 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 |
|