Table-driven radio buttons


Below is a toy Shiny App that works. You can see that the
fluidPage section is completely "tabularized" in the sense that all
components are referred to as elements in vectors or lists. I would lke
to do that in the server section, but have not been able to figure out
how. Can you please help?

The reason for wanting this is that, in the real application, I hope to
specify the contents of all the radio buttons in an external file. I
will not know the contents of the file, or even how many radio buttons
there will be, before runtime. It seems to me that it would be generally
useful to know how to write "table-driven" shiny code.

        cn <- list(list("red", "blue"),list("green","yellow"))
        cv <- list(list("r","b"),list("g","y"))
        cl <- c("Choose one","choose another")
        rid <- c("rb","rb2")
        to <- c("txt","txt2")
        msg <- c("you chose","and chose")
        ui <- fluidPage(
          radioButtons(rid[1], label=cl[1],
                       choiceNames = cn[[1]],
                       choiceValues = cv[[1]]),
          radioButtons(rid[2], label=cl[2],
                       choiceNames = cn[[2]],
                       choiceValues = cv[[2]]),
        server <- function(input, output) {
          output$txt <- renderText({paste(msg[1], input$rb)})
          output$txt2 <- renderText({paste(msg[2], input$rb2 )})
        shinyApp(ui, server)