I'm not entirely sure what you want to achieve.
To slice a data.frame depending on two or more selected inputs is rather trivial.
On the other hand in your code snippet you refer to the shiny function renderUI, which is used of server-side functions. This is one of the most interesting aspects of shiny, but together with reactivity one of the most difficult to grasp for the novice.
This is a simple example (deliberately kept simple in formatting etc.) without renderUI:
library(shiny)
city <- c('London','Tokio','New York')
specialist <- c('ortho', 'perio','gyne', 'rhino')
df <- expand.grid(city = city, specialist = specialist)
opt_specialist <- sort(unique(df$specialist))
opt_city <- sort(unique(df$city))
ui <- fluidPage(
selectInput("spec","Select Specialist",opt_specialist),
selectInput("city","Select City",opt_city),
verbatimTextOutput('city_'),
verbatimTextOutput('spec_')
)
server <- function(input, output, session) {
output$city_ <- renderText({input$city})
output$spec_ <- renderText({input$spec})
}
shinyApp(ui = ui, server = server)
The example below uses server-side programming. Per se wouldn't make much sense to use it, unless in conjunction with more complex server-side operations.
library(shiny)
city <- c('London','Tokio','New York')
specialist <- c('ortho', 'perio','gyne', 'rhino')
df <- expand.grid(city = city, specialist = specialist)
opt_specialist <- sort(unique(df$specialist))
opt_city <- sort(unique(df$city))
ui <- fluidPage(
uiOutput("origin"),
verbatimTextOutput('city_'),
verbatimTextOutput('spec_')
)
server <- function(input, output, session) {
output$origin <- renderUI({
list(
selectInput("spec","Select Specialist",opt_specialist),
selectInput("city","Select City",opt_city)
)
})
output$city_ <- renderText({input$city})
output$spec_ <- renderText({input$spec})
}
shinyApp(ui = ui, server = server)
If I missed anything, please edit or extend your post and I'll amend the response accordingly.