-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
results are now displayed as list with remove buttons
- Loading branch information
1 parent
32244f9
commit 1231822
Showing
18 changed files
with
354 additions
and
420 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
library(shiny) | ||
library(DT) | ||
library(bslib) | ||
library(broom) | ||
library(ggplot2) | ||
library(base64enc) | ||
library(shinyjs) | ||
library(mgcv) | ||
library(RColorBrewer) | ||
library(tidyr) | ||
library(purrr) | ||
library(agricolae) | ||
library(drc) | ||
library(cowplot) | ||
library(MASS) | ||
library(Matrix) | ||
library(shinyjs) | ||
library(equatiomatic) | ||
library(openxlsx) | ||
library(car) | ||
library(cowplot) | ||
library(COMELN) | ||
library(httr) | ||
library(jose) | ||
library(openssl) | ||
Sys.setenv(RUN_MODE = "BROWSER") | ||
setwd("bs/R") | ||
files <- list.files(".") | ||
lapply(files, source) | ||
app <- app() | ||
shiny::shinyApp(app$ui, app$server) | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
library(shiny) | ||
|
||
ui <- fluidPage( | ||
titlePanel("Dynamic List with Remove Buttons"), | ||
sidebarLayout( | ||
sidebarPanel( | ||
numericInput("num_input", "Enter a number:", value = 0), | ||
actionButton("add_btn", "Add to List") | ||
), | ||
mainPanel( | ||
uiOutput("dynamic_list") | ||
) | ||
) | ||
) | ||
|
||
server <- function(input, output, session) { | ||
listValues <- reactiveVal(list()) | ||
observeEvent(input$add_btn, { | ||
current_list <- listValues() | ||
new_item_name <- paste0("item_", length(current_list) + 1) | ||
current_list[[new_item_name]] <- input$num_input | ||
listValues(current_list) | ||
}) | ||
|
||
# Dynamically render the list UI | ||
output$dynamic_list <- renderUI({ | ||
current_list <- listValues() | ||
if (length(current_list) == 0) { | ||
return("No items in the list.") | ||
} | ||
# Create UI elements for each item in the list | ||
tagList(lapply(names(current_list), function(name) { | ||
div( | ||
style = "margin-bottom: 10px;", | ||
span(paste(name, ":", current_list[[name]]), style = "margin-right: 10px;"), | ||
actionButton(name, "Remove", class = "btn-danger btn-sm") | ||
) | ||
})) | ||
}) | ||
|
||
# Observe and handle remove buttons dynamically | ||
observe({ | ||
current_list <- listValues() | ||
lapply(names(current_list), function(name) { | ||
observeEvent(input[[name]], { | ||
current_list <- listValues() | ||
current_list[[name]] <- NULL # Remove the item | ||
listValues(current_list) | ||
}, ignoreInit = TRUE) | ||
}) | ||
}) | ||
} | ||
|
||
shinyApp(ui, server) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,6 @@ Imports: | |
equatiomatic, | ||
openxlsx, | ||
car, | ||
cowplot, | ||
COMELN, | ||
httr, | ||
jose, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.