Spaces:
Running
Running
Update app.R
Browse files
app.R
CHANGED
|
@@ -2095,6 +2095,25 @@ standardize_stuffplus_to_league <- function(data, league_comparison_data) {
|
|
| 2095 |
data <- ensure_stuff_inputs(data)
|
| 2096 |
league_comparison_data <- ensure_stuff_inputs(league_comparison_data)
|
| 2097 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2098 |
data$raw_stuff <- predict(stuffplus_model, data, type = "numeric")$.pred
|
| 2099 |
|
| 2100 |
data <- data %>%
|
|
|
|
| 2095 |
data <- ensure_stuff_inputs(data)
|
| 2096 |
league_comparison_data <- ensure_stuff_inputs(league_comparison_data)
|
| 2097 |
|
| 2098 |
+
# FIX: Convert Date columns to character in both datasets before binding
|
| 2099 |
+
if ("Date" %in% names(data)) data$Date <- as.character(data$Date)
|
| 2100 |
+
if ("Date" %in% names(league_comparison_data)) league_comparison_data$Date <- as.character(league_comparison_data$Date)
|
| 2101 |
+
|
| 2102 |
+
# Also handle any other potentially mismatched columns
|
| 2103 |
+
convert_to_char <- function(df, cols) {
|
| 2104 |
+
for (col in cols) {
|
| 2105 |
+
if (col %in% names(df)) df[[col]] <- as.character(df[[col]])
|
| 2106 |
+
}
|
| 2107 |
+
df
|
| 2108 |
+
}
|
| 2109 |
+
|
| 2110 |
+
problem_cols <- c("Date", "UTCDate", "UTCDateTime", "LocalDateTime",
|
| 2111 |
+
"HomeTeamForeignID", "AwayTeamForeignID", "GameUID",
|
| 2112 |
+
"PitchUID", "PlayID")
|
| 2113 |
+
|
| 2114 |
+
data <- convert_to_char(data, problem_cols)
|
| 2115 |
+
league_comparison_data <- convert_to_char(league_comparison_data, problem_cols)
|
| 2116 |
+
|
| 2117 |
data$raw_stuff <- predict(stuffplus_model, data, type = "numeric")$.pred
|
| 2118 |
|
| 2119 |
data <- data %>%
|