From 062fcfcd8d673e80c0a65c067b180179ce495b58 Mon Sep 17 00:00:00 2001 From: Danielle Callan Date: Sat, 2 Dec 2023 13:58:22 -0500 Subject: [PATCH] add reset data button --- R/server.R | 17 +++++++++++++++++ R/ui.R | 5 +++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/R/server.R b/R/server.R index d6f7ce0..0f0bc82 100644 --- a/R/server.R +++ b/R/server.R @@ -27,6 +27,23 @@ server <- function(input, output, session) { correlationMatrix <- shiny::reactiveValues(corr_matrix = NULL) pValuesMatrix <- shiny::reactiveValues(p_values = NULL) + output$file1 <- renderUI({ + input$resetData ## Create a dependency with the reset button + shiny::fileInput("fileUpload", shiny::strong("Upload Data Table"), accept = c(".tab", "tsv",".rds")) + }) + + output$file2 <- renderUI({ + input$resetData + shiny::fileInput("fileUpload2", shiny::strong("Upload Second Data Table (optional)"), accept = c(".tab", "tsv",".rds")) + }) + + shiny::observeEvent(input$resetData, { + data1$matrix <- NULL + data2$matrix <- NULL + correlationMatrix$corr_matrix <- NULL + pValuesMatrix$p_values <- NULL + }) + shiny::observeEvent({ input$fileUpload input$fileUpload2 diff --git a/R/ui.R b/R/ui.R index 3ff75ff..305587b 100644 --- a/R/ui.R +++ b/R/ui.R @@ -17,8 +17,9 @@ ui <- shiny::fluidPage( shiny::fluidRow( shiny::column(3, shiny::wellPanel( - shiny::fileInput("fileUpload", shiny::strong("Upload Data Table"), accept = c(".tab", "tsv",".rds")), - shiny::fileInput("fileUpload2", shiny::strong("Upload Second Data Table (optional)"), accept = c(".tab", "tsv",".rds")), + uiOutput('file1'), + uiOutput('file2'), + shiny::actionButton("resetData", shiny::strong("Reset Data")), shiny::hr(), #div(style="display:inline-block", selectInput("correlationMethod", shiny::strong("Correlation Method:"),