Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print(data)
- Team v1 v2 v3 v4 v5
- A England Gold Red 50
- B England Silver Blue 30 40
- C Wales Blue 40 30
- D USA Silver Red 50 20
- # Shiny App
- ui <- fluidPage(
- fluidRow(
- column(6, offset=3,
- selectInput(inputId = "variables",
- label = "Variable",
- choices = colnames(data[,c(5:6)])))),
- fluidRow(
- column(2,
- selectInput(inputId = "filter",
- label = "Filter",
- choices = colnames(data[,c(2:4)]),
- selected = 'v2')),
- column(2,
- uiOutput("ui"))
- ),
- plotOutput("all")
- )
- server <- function(input,output){
- output$ui <- renderUI ({
- switch(input$filter,
- "v1" = selectInput(
- "v1", "More filters", data$v1, selected = "England"),
- "v2" = selectInput(
- "v2", "More filters", data$v2, selected = "Gold"),
- "v3" = selectInput(
- "v3", "More filters", data$v3, selected = "Red")
- )
- })
- plott <- reactive({input$ui})
- varr <- reactive({input$filter})
- datasubset <- reactive({subset(data, varr()==plott())})
- finalsubset <- reactive({
- datasubset()[,input$variables]
- })
- output$all <- renderPlot({barplot(finalsubset())
- })
- plott <- reactive({input$ui})
- varr <- reactive({input$filter})
- datasubset <- reactive({subset(data, varr()==plott())})
Add Comment
Please, Sign In to add comment