Spaces:
Running
Running
Update app.R
Browse files
app.R
CHANGED
|
@@ -311,40 +311,27 @@ server <- function(input, output, session) {
|
|
| 311 |
})
|
| 312 |
|
| 313 |
# Auto-compute results on startup with defaults
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
# Store the loaded results in our reactive cache
|
| 336 |
-
cachedResults$data[[label]] <- Qoptimized
|
| 337 |
-
|
| 338 |
-
incProgress(0.8, detail = "Finishing up...")
|
| 339 |
-
|
| 340 |
-
# Update the choice list for previous results
|
| 341 |
-
updateSelectInput(session, "previousResults",
|
| 342 |
-
choices = names(cachedResults$data),
|
| 343 |
-
selected = label)
|
| 344 |
-
}
|
| 345 |
-
})
|
| 346 |
-
}
|
| 347 |
-
},once=TRUE)
|
| 348 |
|
| 349 |
# Generate a new result and cache it
|
| 350 |
# -- In app_ono.R, inside `server` definition --
|
|
|
|
| 311 |
})
|
| 312 |
|
| 313 |
# Auto-compute results on startup with defaults
|
| 314 |
+
session$onFlushed(function() {
|
| 315 |
+
withProgress(message = "Loading default results...", value = 0, {
|
| 316 |
+
incProgress(0.2, detail = "Looking up precomputed results...")
|
| 317 |
+
|
| 318 |
+
# Use default values: Average case, All respondents, lambda 0.01
|
| 319 |
+
lambda_input <- 0.01
|
| 320 |
+
label <- "Case=Average, Group=All, Lambda=0.01"
|
| 321 |
+
lam_char <- gsub("\\.", "PT", as.character(lambda_input))
|
| 322 |
+
filename <- paste0("Average_All_lambda", lam_char, ".rds")
|
| 323 |
+
|
| 324 |
+
file_path <- file.path("AppResults", filename)
|
| 325 |
+
if (file.exists(file_path)) {
|
| 326 |
+
Qoptimized <- readRDS(file_path)
|
| 327 |
+
cachedResults$data[[label]] <- Qoptimized
|
| 328 |
+
incProgress(0.8, detail = "Finishing up...")
|
| 329 |
+
updateSelectInput(session, "previousResults",
|
| 330 |
+
choices = names(cachedResults$data),
|
| 331 |
+
selected = label)
|
| 332 |
+
}
|
| 333 |
+
})
|
| 334 |
+
}, once = TRUE)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 335 |
|
| 336 |
# Generate a new result and cache it
|
| 337 |
# -- In app_ono.R, inside `server` definition --
|