Spaces:
Running
Running
Update app.R
Browse files
app.R
CHANGED
|
@@ -309,43 +309,8 @@ server <- function(input, output, session) {
|
|
| 309 |
}
|
| 310 |
updateSelectInput(session, "factor", choices = factors, selected = factors[1])
|
| 311 |
})
|
| 312 |
-
|
| 313 |
-
# Generate a new result and cache it
|
| 314 |
-
# -- In app_ono.R, inside `server` definition --
|
| 315 |
-
observeEvent(input$compute, {
|
| 316 |
-
withProgress(message = "Retrieving results...", value = 0, {
|
| 317 |
-
incProgress(0.2, detail = "Looking up precomputed results...")
|
| 318 |
-
|
| 319 |
-
# Construct a human-readable label (as before)
|
| 320 |
-
if (input$case_type == "Average") {
|
| 321 |
-
label <- paste("Case=Average, Group=", input$respondent_group,
|
| 322 |
-
", Lambda=", input$lambda_input, sep="")
|
| 323 |
-
lam_char <- gsub("\\.", "PT", as.character(input$lambda_input))
|
| 324 |
-
filename <- paste0("Average_", input$respondent_group,
|
| 325 |
-
"_lambda", lam_char, ".rds")
|
| 326 |
-
} else {
|
| 327 |
-
label <- paste("Case=Adversarial, Lambda=", input$lambda_input, sep="")
|
| 328 |
-
lam_char <- gsub("\\.", "PT", as.character(input$lambda_input))
|
| 329 |
-
filename <- paste0("Adversarial_lambda", lam_char, ".rds")
|
| 330 |
-
}
|
| 331 |
-
|
| 332 |
-
# Read the matching pre-computed .rds file from disk
|
| 333 |
-
file_path <- file.path("AppResults", filename)
|
| 334 |
-
Qoptimized <- readRDS(file_path)
|
| 335 |
-
|
| 336 |
-
# Store the loaded results in our reactive cache
|
| 337 |
-
cachedResults$data[[label]] <- Qoptimized
|
| 338 |
-
|
| 339 |
-
incProgress(0.8, detail = "Finishing up...")
|
| 340 |
-
|
| 341 |
-
# Update the choice list for previous results
|
| 342 |
-
updateSelectInput(session, "previousResults",
|
| 343 |
-
choices = names(cachedResults$data),
|
| 344 |
-
selected = label)
|
| 345 |
-
})
|
| 346 |
-
}, ignoreInit = TRUE)
|
| 347 |
|
| 348 |
-
|
| 349 |
observe({
|
| 350 |
# Only run once when the app starts and inputs are available
|
| 351 |
if (!is.null(input$case_type) && !is.null(input$lambda_input)) {
|
|
@@ -381,6 +346,41 @@ observe({
|
|
| 381 |
}
|
| 382 |
})
|
| 383 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 384 |
# Reactive to pick the result the user wants to display
|
| 385 |
selectedResult <- reactive({
|
| 386 |
validate(
|
|
|
|
| 309 |
}
|
| 310 |
updateSelectInput(session, "factor", choices = factors, selected = factors[1])
|
| 311 |
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 312 |
|
| 313 |
+
# Auto-compute results on startup with defaults
|
| 314 |
observe({
|
| 315 |
# Only run once when the app starts and inputs are available
|
| 316 |
if (!is.null(input$case_type) && !is.null(input$lambda_input)) {
|
|
|
|
| 346 |
}
|
| 347 |
})
|
| 348 |
|
| 349 |
+
# Generate a new result and cache it
|
| 350 |
+
# -- In app_ono.R, inside `server` definition --
|
| 351 |
+
observeEvent(input$compute, {
|
| 352 |
+
withProgress(message = "Retrieving results...", value = 0, {
|
| 353 |
+
incProgress(0.2, detail = "Looking up precomputed results...")
|
| 354 |
+
|
| 355 |
+
# Construct a human-readable label (as before)
|
| 356 |
+
if (input$case_type == "Average") {
|
| 357 |
+
label <- paste("Case=Average, Group=", input$respondent_group,
|
| 358 |
+
", Lambda=", input$lambda_input, sep="")
|
| 359 |
+
lam_char <- gsub("\\.", "PT", as.character(input$lambda_input))
|
| 360 |
+
filename <- paste0("Average_", input$respondent_group,
|
| 361 |
+
"_lambda", lam_char, ".rds")
|
| 362 |
+
} else {
|
| 363 |
+
label <- paste("Case=Adversarial, Lambda=", input$lambda_input, sep="")
|
| 364 |
+
lam_char <- gsub("\\.", "PT", as.character(input$lambda_input))
|
| 365 |
+
filename <- paste0("Adversarial_lambda", lam_char, ".rds")
|
| 366 |
+
}
|
| 367 |
+
|
| 368 |
+
# Read the matching pre-computed .rds file from disk
|
| 369 |
+
file_path <- file.path("AppResults", filename)
|
| 370 |
+
Qoptimized <- readRDS(file_path)
|
| 371 |
+
|
| 372 |
+
# Store the loaded results in our reactive cache
|
| 373 |
+
cachedResults$data[[label]] <- Qoptimized
|
| 374 |
+
|
| 375 |
+
incProgress(0.8, detail = "Finishing up...")
|
| 376 |
+
|
| 377 |
+
# Update the choice list for previous results
|
| 378 |
+
updateSelectInput(session, "previousResults",
|
| 379 |
+
choices = names(cachedResults$data),
|
| 380 |
+
selected = label)
|
| 381 |
+
})
|
| 382 |
+
}, ignoreInit = TRUE)
|
| 383 |
+
|
| 384 |
# Reactive to pick the result the user wants to display
|
| 385 |
selectedResult <- reactive({
|
| 386 |
validate(
|