DaveM2430 commited on
Commit
538fa7c
Β·
verified Β·
1 Parent(s): 1d3dfee

Update app.R

Browse files
Files changed (1) hide show
  1. app.R +25 -0
app.R CHANGED
@@ -49,6 +49,31 @@ load_portal <- function() {
49
  })
50
  }
51
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  # ── Pitch colors ───────────────────────────────────────────────────────────────
53
  pitch_colors <- c(
54
  "Fastball" = "red", "Sinker" = "orange",
 
49
  })
50
  }
51
 
52
+ load_hitter_portal <- function() {
53
+ tryCatch({
54
+ df <- arrow::read_parquet("/app/hitter_portal.parquet")
55
+ names(df) <- tolower(names(df))
56
+ df %>%
57
+ rename(
58
+ Batter = batter,
59
+ Portal = transfer,
60
+ Position = position,
61
+ BatSide = batside,
62
+ Team = team,
63
+ BA = ba,
64
+ OBP = obp,
65
+ SLG = slg
66
+ ) %>%
67
+ distinct(Batter, .keep_all = TRUE)
68
+ },
69
+ error = function(e) {
70
+ message("Hitter portal load failed: ", e$message)
71
+ tibble(Batter=character(), Portal=character(), Position=character(),
72
+ BatSide=character(), Team=character(),
73
+ BA=numeric(), OBP=numeric(), SLG=numeric())
74
+ })
75
+ }
76
+
77
  # ── Pitch colors ───────────────────────────────────────────────────────────────
78
  pitch_colors <- c(
79
  "Fastball" = "red", "Sinker" = "orange",