In my Shiny app my users can upload a file from the server to view the results. I have the user select the file using a selectInput, and then they click an actionButton to load the file. I also want users to be able to delete files and add new files, and I've set that up successfully using separate actionButtons. When the user deletes or adds a file I want to update the selectInput so the deleted files aren't there anymore, and the added files are. I tried this using updateSelectInput in my observeEvent code but its not working. Here's my observeEvent for the delete file portion:
#Delete parameter files
observeEvent(input$delete,{
file.remove(input$input_file) #deletes the file selected in the input_file widget
choices <- list.files("C:/Users/shiny/testapp/", pattern="*.Rdata")
updateSelectInput(session,"input_file",choices) #supposed to update the input_file widget
})
When I run the app with this code in it, two things happen. In the App window, I get this text right above the input_file widget: [object Object And in my R console I get:
Input to asJSON(keep_vec_names=TRUE) is a named vector. In a future version of jsonlite, this option will not be supported, and named vectors will be translated into arrays instead of objects. If you want JSON object output, please use a named list instead. See ?toJSON.
I have included the session parameter in my shinyServer call:
shinyServer(function(input, output, session)
Any advice would be appreciated.
updateSelectInput(session= session, inputId = "input_file", choices = choices). Using positional matching, the third argument inupdateSelectInputislabel, so you aren't actually changing the choices, but trying to assign a vector to thelabel.