Spaces:
Sleeping
Sleeping
Update app.R
Browse files
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",
|