Ah ok, got you. In that case it's a bit simpler.
You just have to put each updateSelectInput in it's own observeEvent that is triggered by the other input.
Also, to avoid both observers triggering at the same time on launch (which would send the updates into an infinite loop of updating each other if the initial selected values didn't correspond with one another) you should add an ignoreInit = TRUE to one of the observers.
Example below.
library(shiny)
df <- data.frame(
col1 = c("Option A","Option B","OptionC"),
col2 = c("Option 1","Option 2","Option 3"),
stringsAsFactors = FALSE
)
ui <- fluidPage(
selectInput("IP1","Input 1", choices = df$col1),
selectInput("IP2","Input 2", choices = df$col2)
)
server <- function(input, output, session) {
observeEvent(input$IP1, {
updateSelectInput(session, "IP2",
selected = df[df$col1 == input$IP1, "col2", drop = TRUE])
})
observeEvent(input$IP2, ignoreInit = TRUE, {
updateSelectInput(session, "IP1",
selected = df[df$col2 == input$IP2, "col1", drop = TRUE])
})
}
shinyApp(ui, server)