diff --git a/shiny-app/server.R b/shiny-app/server.R index c582e25..fbac8dc 100644 --- a/shiny-app/server.R +++ b/shiny-app/server.R @@ -3,26 +3,46 @@ library(ggplot2) # Define server logic required to draw a histogram shinyServer(function(input, output) { + #datasets <- list.files('./data/') emergency2013 <- read.csv("./data/emergency2013.csv") + + + output$fileSelect <- renderUI({ + selectInput("dataSetInput", "Choose your survey:", list.files('./data/')) + }) + + #currentDataset <- read.csv(paste0('./data/', input$dataSetInput)) + + output$columnList <- renderUI({ + currentDataset <- read.csv(paste0('./data/', input$dataSetInput, sep='')) + checkboxGroupInput('show_vars', 'Columns in dataset to show:', names(currentDataset), selected = NULL) + }) + + + output$distPlot <- renderPlot({ - plot(emergency2013$duid, emergency2013$vstctgry) + currentDataset <- read.csv(paste0('./data/', input$dataSetInput, sep='')) + plot(currentDataset$duid, currentDataset$vstctgry) }) output$mytable1 <- renderDataTable({ - emergency2013[, input$show_vars, drop = FALSE] + currentDataset <- read.csv(paste0('./data/', input$dataSetInput, sep='')) + currentDataset[, input$show_vars, drop = FALSE] }) output$mytable2 <- renderDataTable({ - summary(emergency2013[, input$show_vars, drop = FALSE]) + currentDataset <- read.csv(paste0('./data/', input$dataSetInput, sep='')) + summary(currentDataset[, input$show_vars, drop = FALSE]) }) output$myplot <- renderPlot({ + currentDataset <- read.csv(paste0('./data/', input$dataSetInput, sep='')) library(ggplot2) library(corrplot) - pairs(emergency2013[, input$show_vars, drop = FALSE]) + pairs(currentDataset[, input$show_vars, drop = FALSE]) - emergency2013[, input$show_vars, drop = FALSE] + currentDataset[, input$show_vars, drop = FALSE] }) }) \ No newline at end of file diff --git a/shiny-app/ui.R b/shiny-app/ui.R index 6ec3c91..7bd1317 100644 --- a/shiny-app/ui.R +++ b/shiny-app/ui.R @@ -5,11 +5,13 @@ shinyUI(fluidPage( # Application title titlePanel("Hello Shiny!"), - + # Sidebar with a slider input for the number of bins sidebarLayout( sidebarPanel( - checkboxGroupInput('show_vars', 'Columns in dataset to show:', names(emergency2013), selected = NULL)), + uiOutput('fileSelect'), + uiOutput('columnList') + ), # Show a summary table of the selected variables mainPanel( tabsetPanel( @@ -20,4 +22,4 @@ shinyUI(fluidPage( ) ) ) -) \ No newline at end of file +)