observe({
updateSelectInput(session,"IP2",selected = table$Column2[table$Column1==input$IP1] # How to update the input w.r.t second input
updateSelectInput(session,"IP1",selected = table$Column1[table$Column2==input$IP2] # This one loops the value b/w previous one and new one.
tableOP<- subset(table,Column1== input$IP1)
output$table1<-renderDataTable(tableOP)
})
On Googling I found that functions isolate() or observeEvent() can be used. But I don't know where and how. I tried using them but didn't get the results.
Thank you for the link and support.
I tried using the methodology to the best of my knowledge.
But, my need is slightly different.
In the link the selectInputs are filtered to values available on first choice.
But my need is that the selectInputs do not filter out values but only, select the value which is related to the first selection. ( The first selection can be from any of the input).
Like
selectInput("IP1","Input 1",choices = c("Option A","Option B","OptionC")
selectInput("IP2","Input 2",choices =c("Option 1","Option 2","Option 3")
# if I select "Option A" from IP1
#Option1 of IP2 is automatically selected "NOT REMOVE REMAINING OPTIONS"
#OR, if I select "Option 1" from IP 2 "Option A" is automatically selected in IP1
# This selection must be reproducible i.e. I can do selection any number of times.
```
Thanking You for your help.
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.
Just a comment about this approach, if you restrict the options this way, what is the point in having two inputs? would not be simpler to just have both combined? because you can't get other combinations anyways.
Actually, the two options are important selection factors for getting required table.
Some people in my work, are familiar with Options (A,B,C), rest are with Options (1,2,3). In general I could have subset the table with Options (A,B,C) OR (1,2,3) but, for sake of simplicity for all people I thought of providing both inputs.
Also, in actual dataset Options (A,B,C) have more than one combinations in second input i.e. Options(1,2,3) like, (A-1,A-2,A-3). So, a second level of drill down is applicable here. Like someone can choose Option A and Option 2 to get required table output.
Thank You for the help, I was not familiar with observeEvent() with ignoreInit argument. Thank You for teaching me that.
I got the desired output and the "killing loop" did not occur.
Just, if I can bother you one last time,
On applying the above methodology the selectInputs are not reproducible. I mean that once I have done the selection I have to restart the app to make another selection.
I can make a resetInput button using observe() but, still it would mean same as resetting the app.
I am using selectInput(…,multiple ==TRUE) # in both the inputs.
By any means can I just use Backspace to remove the selections.
Which generally work when the app is simple. But, due to slight complexity this backspace is not working.
Because the drop down choices are getting removed and only selected choice is visible.