I need to have one selectInput to update on selected values in another selectInput and then use the updated one to select data from the dataset for plotting.
I use the following in ui:
selectizeInput("select_industry", "Industry groups",
choices = c(sort(unique(employ$industry_group))),
multiple = FALSE,
selected = 'Sector 10 - Information media & telecommunications (J)'
),
uiOutput("select_industry_group")
and this is my server
#select industry
output$select_industry_group <- renderUI({
# check whether user wants to filter by cyl;
# if not, then filter by selection
if ("All industry groups" %in% input$select_industry) {
dat <- employ
} else {
dat <- employ %>%
filter(industry_group %in% input$select_industry)
}
# get available industry values
group <- sort(unique(dat$var))
# render selectizeInput
selectizeInput("select_industry_item", "Industry",
choices = c(group),
multiple = FALSE,
selected="Communication services")
})
#plot - industry
output$employ1_plot<-renderPlotly({
employ_ggplot<-employ%>%
filter(var==input$select_industry_item)
...
})
It returns an error... What am i doing wrong?