cjerzak commited on
Commit
05791f3
·
verified ·
1 Parent(s): 34503a7

Update app.R

Browse files
Files changed (1) hide show
  1. app.R +36 -31
app.R CHANGED
@@ -349,37 +349,42 @@ observe({
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({
 
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
+ # Isolate input values to prevent reactive dependencies
356
+ case_type <- isolate(input$case_type)
357
+ respondent_group <- isolate(input$respondent_group)
358
+ lambda_input <- isolate(input$lambda_input)
359
+
360
+ # Construct a human-readable label
361
+ if (case_type == "Average") {
362
+ label <- paste("Case=Average, Group=", respondent_group,
363
+ ", Lambda=", lambda_input, sep="")
364
+ lam_char <- gsub("\\.", "PT", as.character(lambda_input))
365
+ filename <- paste0("Average_", respondent_group,
366
+ "_lambda", lam_char, ".rds")
367
+ } else {
368
+ label <- paste("Case=Adversarial, Lambda=", lambda_input, sep="")
369
+ lam_char <- gsub("\\.", "PT", as.character(lambda_input))
370
+ filename <- paste0("Adversarial_lambda", lam_char, ".rds")
371
+ }
372
+
373
+ # Read the matching pre-computed .rds file from disk
374
+ file_path <- file.path("AppResults", filename)
375
+ Qoptimized <- readRDS(file_path)
376
+
377
+ # Store the loaded results in our reactive cache
378
+ cachedResults$data[[label]] <- Qoptimized
379
+
380
+ incProgress(0.8, detail = "Finishing up...")
381
+
382
+ # Update the choice list for previous results
383
+ updateSelectInput(session, "previousResults",
384
+ choices = names(cachedResults$data),
385
+ selected = label)
386
+ })
387
+ }, ignoreInit = TRUE)
388
 
389
  # Reactive to pick the result the user wants to display
390
  selectedResult <- reactive({