Spaces:
Running
Running
Update app.R
Browse files
app.R
CHANGED
@@ -54,7 +54,8 @@ plot_factor <- function(pi_star_list,
|
|
54 |
df$Level_num + ifelse(df$Strategy == "Democrat", -0.05, 0.05)
|
55 |
|
56 |
ggplot(df, aes(x = x_dodged, y = Probability, color = Strategy)) +
|
57 |
-
geom_segment(aes(
|
|
|
58 |
geom_point(size = 2.5) +
|
59 |
geom_text(aes(label = sprintf("%.2f", Probability)),
|
60 |
vjust = -0.7, size = 3) +
|
@@ -171,11 +172,13 @@ ui <- fluidPage(
|
|
171 |
condition = "input.case_type == 'Average'",
|
172 |
selectInput("respondent_group", "Respondent Group:",
|
173 |
choices = c("All", "Democrat", "Independent", "Republican"),
|
174 |
-
selected = "
|
175 |
),
|
176 |
numericInput("lambda_input", "Lambda (regularization):",
|
177 |
value = 0.01, min = 1e-6, max = 10, step = 0.01),
|
178 |
actionButton("compute", "Compute Results", class = "btn-primary"),
|
|
|
|
|
179 |
hr(),
|
180 |
h4("Visualization"),
|
181 |
selectInput("factor", "Select Factor to Display:", choices = NULL),
|
@@ -275,6 +278,9 @@ server <- function(input, output, session) {
|
|
275 |
updateSelectInput(session, "previousResults",
|
276 |
choices = names(cachedResults$data),
|
277 |
selected = label)
|
|
|
|
|
|
|
278 |
shinyjs::disable("compute")
|
279 |
showNotification(sprintf("Job '%s' submitted …", label),
|
280 |
type = "message", duration = 3)
|
@@ -422,6 +428,7 @@ server <- function(input, output, session) {
|
|
422 |
updateSelectInput(session, "previousResults",
|
423 |
choices = names(cachedResults$data),
|
424 |
selected = label)
|
|
|
425 |
shinyjs::enable("compute")
|
426 |
showNotification(sprintf("Job '%s' finished (%.1f s).",
|
427 |
label, res$runtime_seconds),
|
@@ -430,6 +437,7 @@ server <- function(input, output, session) {
|
|
430 |
(function(err) {
|
431 |
runningFlags$active[[label]] <- FALSE
|
432 |
cachedResults$data[[label]] <- NULL
|
|
|
433 |
shinyjs::enable("compute")
|
434 |
showNotification(paste("Error in", label, ":", err$message),
|
435 |
type = "error", duration = 8)
|
|
|
54 |
df$Level_num + ifelse(df$Strategy == "Democrat", -0.05, 0.05)
|
55 |
|
56 |
ggplot(df, aes(x = x_dodged, y = Probability, color = Strategy)) +
|
57 |
+
geom_segment(aes(x = x_dodged, xend = x_dodged,
|
58 |
+
y = 0, yend = Probability), size = 0.3) +
|
59 |
geom_point(size = 2.5) +
|
60 |
geom_text(aes(label = sprintf("%.2f", Probability)),
|
61 |
vjust = -0.7, size = 3) +
|
|
|
172 |
condition = "input.case_type == 'Average'",
|
173 |
selectInput("respondent_group", "Respondent Group:",
|
174 |
choices = c("All", "Democrat", "Independent", "Republican"),
|
175 |
+
selected = "Democrat")
|
176 |
),
|
177 |
numericInput("lambda_input", "Lambda (regularization):",
|
178 |
value = 0.01, min = 1e-6, max = 10, step = 0.01),
|
179 |
actionButton("compute", "Compute Results", class = "btn-primary"),
|
180 |
+
div(id = "status_text",
|
181 |
+
style = "margin-top:6px; font-style:italic; color:#555;"),
|
182 |
hr(),
|
183 |
h4("Visualization"),
|
184 |
selectInput("factor", "Select Factor to Display:", choices = NULL),
|
|
|
278 |
updateSelectInput(session, "previousResults",
|
279 |
choices = names(cachedResults$data),
|
280 |
selected = label)
|
281 |
+
shinyjs::html("status_text", "")
|
282 |
+
shinyjs::html("status_text", "submitting…") # Immediately show “submitting…”
|
283 |
+
shinyjs::delay(2000, shinyjs::html("status_text", "submitted")) # Two‑second later switch to “submitted”
|
284 |
shinyjs::disable("compute")
|
285 |
showNotification(sprintf("Job '%s' submitted …", label),
|
286 |
type = "message", duration = 3)
|
|
|
428 |
updateSelectInput(session, "previousResults",
|
429 |
choices = names(cachedResults$data),
|
430 |
selected = label)
|
431 |
+
shinyjs::html("status_text", "complete!")
|
432 |
shinyjs::enable("compute")
|
433 |
showNotification(sprintf("Job '%s' finished (%.1f s).",
|
434 |
label, res$runtime_seconds),
|
|
|
437 |
(function(err) {
|
438 |
runningFlags$active[[label]] <- FALSE
|
439 |
cachedResults$data[[label]] <- NULL
|
440 |
+
shinyjs::html("status_text", "error – see log")
|
441 |
shinyjs::enable("compute")
|
442 |
showNotification(paste("Error in", label, ":", err$message),
|
443 |
type = "error", duration = 8)
|