## Only run examples in interactive R sessions
if (interactive()) {
ui <- fluidPage(
p("The first radio button group controls the second"),
radioButtons("inRadioButtons", "Input radio buttons",
c("Item A", "Item B", "Item C")),
radioButtons("inRadioButtons2", "Input radio buttons 2",
c("Item A", "Item B", "Item C"))
)
server <- function(input, output, session) {
observe({
x <- input$inRadioButtons
# Can also set the label and select items
updateRadioButtons(session, "inRadioButtons2",
label = paste("radioButtons label", x),
choices = x,
selected = x
)
})
}
shinyApp(ui, server)
}
Run the code above in your browser using DataLab