Spaces:
Running
Running
Update app.R
Browse files
app.R
CHANGED
|
@@ -2095,25 +2095,19 @@ 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 |
-
|
| 2099 |
-
|
| 2100 |
-
|
| 2101 |
-
|
| 2102 |
-
|
| 2103 |
-
|
| 2104 |
-
|
| 2105 |
-
|
|
|
|
|
|
|
| 2106 |
}
|
| 2107 |
-
df
|
| 2108 |
}
|
| 2109 |
|
| 2110 |
-
problem_cols <- c("Date", "Time", "Tilt", "UTCTime" "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 %>%
|
|
|
|
| 2095 |
data <- ensure_stuff_inputs(data)
|
| 2096 |
league_comparison_data <- ensure_stuff_inputs(league_comparison_data)
|
| 2097 |
|
| 2098 |
+
common_cols <- intersect(names(data), names(league_comparison_data))
|
| 2099 |
+
|
| 2100 |
+
for (col in common_cols) {
|
| 2101 |
+
type1 <- class(data[[col]])[1]
|
| 2102 |
+
type2 <- class(league_comparison_data[[col]])[1]
|
| 2103 |
+
|
| 2104 |
+
if (type1 != type2) {
|
| 2105 |
+
message("Converting mismatched column '", col, "': ", type1, " vs ", type2)
|
| 2106 |
+
data[[col]] <- as.character(data[[col]])
|
| 2107 |
+
league_comparison_data[[col]] <- as.character(league_comparison_data[[col]])
|
| 2108 |
}
|
|
|
|
| 2109 |
}
|
| 2110 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2111 |
data$raw_stuff <- predict(stuffplus_model, data, type = "numeric")$.pred
|
| 2112 |
|
| 2113 |
data <- data %>%
|