igroffman commited on
Commit
ed13c12
·
verified ·
1 Parent(s): 4c623b5

Update app.R

Browse files
Files changed (1) hide show
  1. app.R +9 -9
app.R CHANGED
@@ -1328,11 +1328,11 @@ calculate_tableau_release_data <- function(pitcher_df) {
1328
  filter(TaggedPitchType %in% filter_types) %>%
1329
  group_by(TaggedPitchType) %>%
1330
  summarise(
1331
- `Rel Ht` = round(mean(RelHeight, na.rm = TRUE), 2),
1332
- `vs FB` = ifelse(is.na(fb_ht), NA, round((mean(RelHeight, na.rm = TRUE) - fb_ht) * 12, 0)),
1333
- `Rel Side` = round(mean(RelSide, na.rm = TRUE), 2),
1334
- `vs FB (S)` = ifelse(is.na(fb_side), NA, round((mean(RelSide, na.rm = TRUE) - fb_side) * 12, 0)),
1335
- `Ext` = round(mean(Extension, na.rm = TRUE), 2),
1336
  .groups = "drop"
1337
  )
1338
  }
@@ -1366,7 +1366,7 @@ create_tableau_location_plot <- function(pitcher_df, pitch_colors) {
1366
  if (nrow(df) == 0) {
1367
  return(ggplot() + theme_void() +
1368
  labs(title = "Location Report") +
1369
- theme(plot.title = element_text(size = 10, face = "bold", hjust = 0.5)))
1370
  }
1371
 
1372
  zone_left <- -0.8333; zone_right <- 0.8333
@@ -1446,13 +1446,13 @@ create_tableau_movement_plot <- function(pitcher_df, pitch_colors) {
1446
  if (nrow(df) == 0) {
1447
  return(ggplot() + theme_void() +
1448
  labs(title = "Movement Profile") +
1449
- theme(plot.title = element_text(size = 10, face = "bold", hjust = 0.5)))
1450
  }
1451
 
1452
  ggplot(df, aes(x = HorzBreak, y = InducedVertBreak, color = TaggedPitchType)) +
1453
  geom_vline(xintercept = 0, color = "black", linewidth = 0.4) +
1454
  geom_hline(yintercept = 0, color = "black", linewidth = 0.4) +
1455
- geom_point(size = 2.5, alpha = 0.8) +
1456
  scale_color_manual(values = pitch_colors) +
1457
  coord_cartesian(xlim = c(-25, 25), ylim = c(-25, 25)) +
1458
  labs(title = "Movement Profile", x = "HB", y = "IVB") +
@@ -1496,7 +1496,7 @@ create_tableau_release_plot <- function(pitcher_df, pitch_colors) {
1496
  annotate("rect", xmin = -0.5, xmax = 0.5, ymin = 0.85, ymax = 1.05,
1497
  fill = "white", color = "gray40", linewidth = 0.3) +
1498
  geom_vline(xintercept = 0, color = "gray60", linetype = "dashed", linewidth = 0.3) +
1499
- geom_point(aes(color = TaggedPitchType), size = 2.5, alpha = 0.8) +
1500
  scale_color_manual(values = pitch_colors) +
1501
  coord_cartesian(xlim = c(-4, 4), ylim = c(0, 7)) +
1502
  labs(title = "Release Plot", x = "Side", y = "Height") +
 
1328
  filter(TaggedPitchType %in% filter_types) %>%
1329
  group_by(TaggedPitchType) %>%
1330
  summarise(
1331
+ `Avg. Rel Ht` = round(mean(RelHeight, na.rm = TRUE), 2),
1332
+ `Rel Ht vs. FB` = ifelse(is.na(fb_ht), NA, round((mean(RelHeight, na.rm = TRUE) - fb_ht) * 12, 0)),
1333
+ `Avg. Rel Side` = round(mean(RelSide, na.rm = TRUE), 2),
1334
+ `Rel Side vs. FB` = ifelse(is.na(fb_side), NA, round((mean(RelSide, na.rm = TRUE) - fb_side) * 12, 0)),
1335
+ `Avg. Ext` = round(mean(Extension, na.rm = TRUE), 2),
1336
  .groups = "drop"
1337
  )
1338
  }
 
1366
  if (nrow(df) == 0) {
1367
  return(ggplot() + theme_void() +
1368
  labs(title = "Location Report") +
1369
+ theme(plot.title = element_text(size = 12, face = "bold", hjust = 0.5)))
1370
  }
1371
 
1372
  zone_left <- -0.8333; zone_right <- 0.8333
 
1446
  if (nrow(df) == 0) {
1447
  return(ggplot() + theme_void() +
1448
  labs(title = "Movement Profile") +
1449
+ theme(plot.title = element_text(size = 12, face = "bold", hjust = 0.5)))
1450
  }
1451
 
1452
  ggplot(df, aes(x = HorzBreak, y = InducedVertBreak, color = TaggedPitchType)) +
1453
  geom_vline(xintercept = 0, color = "black", linewidth = 0.4) +
1454
  geom_hline(yintercept = 0, color = "black", linewidth = 0.4) +
1455
+ geom_point(size = 4, alpha = 1, shape = 21, color = "black", stroke = 2) +
1456
  scale_color_manual(values = pitch_colors) +
1457
  coord_cartesian(xlim = c(-25, 25), ylim = c(-25, 25)) +
1458
  labs(title = "Movement Profile", x = "HB", y = "IVB") +
 
1496
  annotate("rect", xmin = -0.5, xmax = 0.5, ymin = 0.85, ymax = 1.05,
1497
  fill = "white", color = "gray40", linewidth = 0.3) +
1498
  geom_vline(xintercept = 0, color = "gray60", linetype = "dashed", linewidth = 0.3) +
1499
+ geom_point(aes(color = TaggedPitchType), size = 4, alpha = 1, shape = 21, stroke = 2, color = "black") +
1500
  scale_color_manual(values = pitch_colors) +
1501
  coord_cartesian(xlim = c(-4, 4), ylim = c(0, 7)) +
1502
  labs(title = "Release Plot", x = "Side", y = "Height") +