cjerzak commited on
Commit
f556ca2
·
verified ·
1 Parent(s): b5f026a

Update app.R

Browse files
Files changed (1) hide show
  1. app.R +30 -32
app.R CHANGED
@@ -309,41 +309,39 @@ 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
  # Reactive to pick the result the user wants to display
349
  selectedResult <- reactive({
 
309
  }
310
  updateSelectInput(session, "factor", choices = factors, selected = factors[1])
311
  })
312
+
313
+ # perform computation function
314
+ performComputation <- function() {
315
+ withProgress(message = "Retrieving results...", value = 0, {
316
+ incProgress(0.2, detail = "Looking up precomputed results...")
317
+ # Construct a human-readable label (as before)
318
+ if (input$case_type == "Average") {
319
+ label <- paste("Case=Average, Group=", input$respondent_group,
320
+ ", Lambda=", input$lambda_input, sep="")
321
+ lam_char <- gsub("\\.", "PT", as.character(input$lambda_input))
322
+ filename <- paste0("Average_", input$respondent_group,
323
+ "_lambda", lam_char, ".rds")
324
+ } else {
325
+ label <- paste("Case=Adversarial, Lambda=", input$lambda_input, sep="")
326
+ lam_char <- gsub("\\.", "PT", as.character(input$lambda_input))
327
+ filename <- paste0("Adversarial_lambda", lam_char, ".rds")
328
+ }
329
+ # Read the matching pre-computed .rds file from disk
330
+ file_path <- file.path("AppResults", filename)
331
+ Qoptimized <- readRDS(file_path)
332
+ # Store the loaded results in our reactive cache
333
+ cachedResults$data[[label]] <- Qoptimized
334
+ incProgress(0.8, detail = "Finishing up...")
335
+ # Update the choice list for previous results
336
+ updateSelectInput(session, "previousResults",
337
+ choices = names(cachedResults$data),
338
+ selected = label)
339
+ })
340
+ }
341
 
342
  # Generate a new result and cache it
343
  # -- In app_ono.R, inside `server` definition --
344
+ observeEvent(input$compute, performComputation(), ignoreInit = FALSE)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
345
 
346
  # Reactive to pick the result the user wants to display
347
  selectedResult <- reactive({