Basically, I want the output DataTable to switch to the page that has the values matching with the Input selection value (radioButtons
). I know I can do a simple filter but that would remove all the other rows that do not match the criteria which I do not want.
Any help is appreciated! Thanks!
library(shiny)
library(DT)
ui <- basicPage(
h3("The mtcars data"),
fluidRow(column(2,
offset = 1,
radioButtons("valSel", strong("Gear"),
inline = TRUE,
choices = c("3", "4", "5"),
selected = "3")),
fluidRow(column(10,
offset = 1,
dataTableOutput("mytable")))
)
)
server <- function(input, output) {
output$mytable = DT::renderDataTable({
mtcars[mtcars$gear == input$valSel, ]
})
}
shinyApp(ui, server)
Created on 2021-05-27 by the reprex package (v2.0.0)