How to make selectInput choices react to other conditions?


I'm recently new to R Shiny, and want to ask about a question.

Suppose I have big category "A" and "B", which have small categories "A1", "A2", "A3", and "B1", "B2", "B3", "B4" respectively.

I would like to make the user choose the categories using selectInput. I want to make selectInput choices of the small categories only appear according to my choose of the big categories. For example,

for first selectInput I can make the user choose "A" or "B" and I can make this, but for the second selectInput I want to make the user choose "A1", "A2", or "A3" (not showing "B1" to "B4") only when the user already chose "A" before, and the similarly for "B" also.

Is there a simple way to make this? Thank you in advance.

Are the categories pre determined, or based on data?


ui <- fluidPage(

server <- function(input, output, session) {
  output$second <- renderUI({
  output$showselection <- renderText({
    paste(input$base,    input$secondary)

shinyApp(ui, server)

Thank you very much! This was what I exactly wanted.

In fact this is the first time I saw functions like 'uiOutput', 'verbatimTextOutput', or 'renderUI', which I couldn't find on tutorials for R shiny. Are there any posts to learn about those functions, other than help pages?

Thank you!

Thank you very much!!