library(shiny)
library(dplyr)
library(DT)
ui <- fluidPage(
fluidRow(
checkboxGroupInput("grade", "Filter by Grade", c("1st", "2nd", "3rd"), selected = "1st")
),
fluidRow(
column(12,
dataTableOutput('gradetable')
)
)
)
server <- function(input, output) {
testscores <- structure(list(Name = structure(c(4L, 1L, 3L, 2L), .Label = c("Carla",
"Kelsey", "Matt", "Sam"), class = "factor"), Grade = structure(c(1L,
2L, 1L, 3L), .Label = c("1st", "2nd", "3rd"), class = "factor"),
Test1 = c(88L, 82L, 90L, 92L), Test2 = c(92L, 88L, 76L, 96L
)), .Names = c("Name", "Grade", "Test1", "Test2"), class = "data.frame", row.names = c(NA,
-4L))
# product definition
output$gradetable <- renderDataTable({
testscores %>% filter(Grade == input$grade) %>% datatable
})
}
# Run the application
shinyApp(ui = ui, server = server)