Приведенный ниже пример блестящего кода удовлетворит ваше требование.
library(shiny)
ui <- fluidPage(selectInput(inputId = "selectedName", label = "Select a name",
choices = levels(data$name)),
tableOutput("table")
)
server <- function(input, output, session){
df <- reactive({data.frame(data[data$name == input$selectedName,])
})
output$table <- renderTable( df() )
}
shinyApp(ui = ui, server = server)
Данные, используемые в коде, приведены ниже.
dput(data)
structure(list(name = structure(c(1L, 2L, 6L, 5L, 4L, 3L, 1L,
1L, 1L, 2L, 2L, 2L, 5L, 5L, 5L), .Label = c("aaa", "ddd", "eee",
"ggg", "ppp", "yyy"), class = "factor"), test = c(14, 88, 36,
25, 56, 34, 30, 75, 44, 19, 83, 49, 87, 62, 50), result = c(25,
44, 39, 88, 10, 44, 58, 22, 94, 56, 73, 15, 84, 223, 45)), .Names = c("name",
"test", "result"), row.names = c(NA, -15L), class = "data.frame")
Фильтрация кадра данных зависит от выбора, который мы делаем в selectInput
выпадающий.