daily pastebin goal
68%
SHARE
TWEET

Untitled

a guest Apr 16th, 2018 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. print(data)
  2.     Team v1       v2      v3    v4   v5
  3. A    England  Gold    Red        50
  4. B    England  Silver  Blue  30   40
  5. C    Wales            Blue  40   30
  6. D    USA      Silver  Red   50   20
  7.    
  8. # Shiny App
  9.      ui <- fluidPage(
  10.      fluidRow(
  11. column(6, offset=3,
  12. selectInput(inputId = "variables",
  13.         label = "Variable",
  14.         choices = colnames(data[,c(5:6)])))),
  15. fluidRow(
  16. column(2,
  17.        selectInput(inputId = "filter",
  18.                    label = "Filter",
  19.                    choices = colnames(data[,c(2:4)]),
  20.                    selected = 'v2')),
  21. column(2,
  22.        uiOutput("ui"))
  23. ),
  24. plotOutput("all")
  25. )
  26.    
  27. server <- function(input,output){
  28. output$ui <- renderUI ({
  29. switch(input$filter,
  30.        "v1" = selectInput(
  31.          "v1", "More filters", data$v1, selected = "England"),
  32.        "v2" = selectInput(
  33.          "v2", "More filters", data$v2, selected = "Gold"),
  34.        "v3" = selectInput(
  35.          "v3", "More filters", data$v3, selected = "Red")
  36.   )
  37.   })
  38.  
  39.   plott <- reactive({input$ui})
  40.   varr <- reactive({input$filter})
  41.  
  42.   datasubset <- reactive({subset(data, varr()==plott())})
  43.  
  44.   finalsubset <- reactive({
  45.     datasubset()[,input$variables]
  46.   })
  47.  
  48.   output$all <- renderPlot({barplot(finalsubset())
  49.   })
  50.    
  51. plott <- reactive({input$ui})
  52. varr <- reactive({input$filter})
  53.  
  54.  datasubset <- reactive({subset(data, varr()==plott())})
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top