Make conditionalPanel depend on files uploaded with fileInput

后端 未结 1 1794
小蘑菇
小蘑菇 2020-11-27 17:33

So I\'m trying to make a shiny app where I have a button which only shows up if files have been uploaded; for this im using conditionalPanel.

ui.R:

r         


        
相关标签:
1条回答
  • 2020-11-27 18:07

    You have to make a reactive output returning the status of the uploading and set the option suspendWhenHidden of this output to FALSE.

    More precisely, in server.R you surely have a reactive function, say getData() to make a dataframe from the uploaded file. Then do this:

      getData <- reactive({
        if(is.null(input$files)) return(NULL)
        ......
      })
      output$fileUploaded <- reactive({
        return(!is.null(getData()))
      })
      outputOptions(output, 'fileUploaded', suspendWhenHidden=FALSE)
    

    And in ui.R you can use conditionalPanel() by doing:

    conditionalPanel("output.fileUploaded",
       ......
    
    0 讨论(0)
提交回复
热议问题