Spaces:
Sleeping
Sleeping
Update app.R
Browse files
app.R
CHANGED
|
@@ -115,7 +115,14 @@ build_pitcher_stats <- function(df, min_pitches) {
|
|
| 115 |
`Hard Hit%` = round(hh_n / pmax(bip_n, 1) * 100, 1),
|
| 116 |
`Plot` = paste0('<button class="plot-btn" data-pitcher="',
|
| 117 |
gsub('"', '"', Pitcher),
|
| 118 |
-
'">📊 View</button>')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
) %>%
|
| 120 |
filter(
|
| 121 |
!is.na(Name),
|
|
@@ -123,7 +130,8 @@ build_pitcher_stats <- function(df, min_pitches) {
|
|
| 123 |
grepl(" ", trimws(Name))
|
| 124 |
) %>%
|
| 125 |
select(Name, Level, Team, Pitches, `FB Velo`, `Zone%`, `Strike%`,
|
| 126 |
-
`K's`, `BB's`, `K/BB`, `Whiff%`, `Chase%`, `Hard Hit%`,
|
|
|
|
| 127 |
arrange(desc(Pitches))
|
| 128 |
}
|
| 129 |
|
|
@@ -171,6 +179,13 @@ ui <- fluidPage(
|
|
| 171 |
padding:4px 10px; font-size:12px; cursor:pointer; font-weight:600; }
|
| 172 |
.plot-btn:hover { background:#003366; }
|
| 173 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 174 |
.modal-overlay { position:fixed; top:0; left:0; width:100%; height:100%;
|
| 175 |
background:rgba(0,0,0,0.55); z-index:2000;
|
| 176 |
display:flex; align-items:center; justify-content:center; }
|
|
@@ -373,10 +388,10 @@ server <- function(input, output, session) {
|
|
| 373 |
order = list(list(3, "desc")),
|
| 374 |
orderMulti = FALSE,
|
| 375 |
dom = "lfrtip",
|
| 376 |
-
columnDefs
|
| 377 |
list(className = "dt-left", targets = 0:1),
|
| 378 |
-
list(className = "dt-center", targets = 2:
|
| 379 |
-
list(orderable = FALSE, targets = 13)
|
| 380 |
),
|
| 381 |
initComplete = JS("function(settings, json) {
|
| 382 |
$('#loading_msg').hide();
|
|
|
|
| 115 |
`Hard Hit%` = round(hh_n / pmax(bip_n, 1) * 100, 1),
|
| 116 |
`Plot` = paste0('<button class="plot-btn" data-pitcher="',
|
| 117 |
gsub('"', '"', Pitcher),
|
| 118 |
+
'">📊 View</button>'),
|
| 119 |
+
`Twitter` = paste0('<a href="https://www.google.com/search?q=',
|
| 120 |
+
gsub(" ", "+", sapply(Pitcher, function(n) {
|
| 121 |
+
parts <- strsplit(n, ", ")[[1]]
|
| 122 |
+
if (length(parts)==2) paste(trimws(parts[2]),trimws(parts[1])) else n
|
| 123 |
+
})),
|
| 124 |
+
'+baseball+twitter" target="_blank">',
|
| 125 |
+
'🐦 Search</a>')
|
| 126 |
) %>%
|
| 127 |
filter(
|
| 128 |
!is.na(Name),
|
|
|
|
| 130 |
grepl(" ", trimws(Name))
|
| 131 |
) %>%
|
| 132 |
select(Name, Level, Team, Pitches, `FB Velo`, `Zone%`, `Strike%`,
|
| 133 |
+
`K's`, `BB's`, `K/BB`, `Whiff%`, `Chase%`, `Hard Hit%`,
|
| 134 |
+
`Plot`, `Twitter`) %>%
|
| 135 |
arrange(desc(Pitches))
|
| 136 |
}
|
| 137 |
|
|
|
|
| 179 |
padding:4px 10px; font-size:12px; cursor:pointer; font-weight:600; }
|
| 180 |
.plot-btn:hover { background:#003366; }
|
| 181 |
|
| 182 |
+
table.dataTable tbody td a {
|
| 183 |
+
color:#002147; font-weight:600; font-size:12px;
|
| 184 |
+
text-decoration:none; background:#e8f0fe; border-radius:4px;
|
| 185 |
+
padding:3px 8px; display:inline-block;
|
| 186 |
+
}
|
| 187 |
+
table.dataTable tbody td a:hover { background:#002147; color:white; }
|
| 188 |
+
|
| 189 |
.modal-overlay { position:fixed; top:0; left:0; width:100%; height:100%;
|
| 190 |
background:rgba(0,0,0,0.55); z-index:2000;
|
| 191 |
display:flex; align-items:center; justify-content:center; }
|
|
|
|
| 388 |
order = list(list(3, "desc")),
|
| 389 |
orderMulti = FALSE,
|
| 390 |
dom = "lfrtip",
|
| 391 |
+
columnDefs = list(
|
| 392 |
list(className = "dt-left", targets = 0:1),
|
| 393 |
+
list(className = "dt-center", targets = 2:14),
|
| 394 |
+
list(orderable = FALSE, targets = c(13, 14))
|
| 395 |
),
|
| 396 |
initComplete = JS("function(settings, json) {
|
| 397 |
$('#loading_msg').hide();
|