When using observe event and update var selection it resets every time to top in drop down list
I have a very large data set, when one unit is selected it filters the dataset so the next drop down list only contains parameters related to that unit to plot. This works except that the drop down list refreshes on all inputs not just the changing of the unit, I want it to refresh only when the unit is changed. ie the drop down list becomes unit a temperature, unit a pressure, unit a level etc when unit a is selected. unit b temperature, unit b pressure etc.
However, if I chose unit b the drop down list becomes unit b temperature, unit b temperature etc with the temperature being the first in the list and automatically shown on the chart, if I click on the drop down list and chose pressure, the chart will briefly show the pressure but then apparently the observe event is triggered, the list resets itself and defaults back to temperature
some portions of code summerized for clarity and not here word for word
# Define UI for application that plots User Input and filtered data
ui <- navbarPage( "Viewer",
tabPanel("Chart" , plotOutput(outputId = "newPlot"),
box(selectInput("Unit", "Chose Unit",c(a,b,c),selected = NULL)),
box(varSelectInput("Parameter", "Select the Parameter
to Plot:",TracePlot, selected = NULL )),
))
# Define server logic
server <- function(input, output,session) { output$newPlot <-
renderPlot({
TracePlot<-filters on unit selected (input$Unit)
observeEvent(input$Unit, updateVarSelectInput(session,"Parameter",
"Select the Parameter to Plot:", TracePlot,selected = NULL) )
ggplot(Trace, aes_string(y=input$Parameter, x=input$Batch_Or_Step)) +
geom_point()
})
}
# Run the application
shinyApp(ui = ui, server = server)