Customize datasets

This commit is contained in:
geoffreyli 2015-11-07 16:36:45 -05:00
parent 2627c1d12f
commit 0a09137353
2 changed files with 30 additions and 8 deletions

View File

@ -3,26 +3,46 @@ library(ggplot2)
# Define server logic required to draw a histogram # Define server logic required to draw a histogram
shinyServer(function(input, output) { shinyServer(function(input, output) {
#datasets <- list.files('./data/')
emergency2013 <- read.csv("./data/emergency2013.csv") 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({ output$distPlot <- renderPlot({
plot(emergency2013$duid, emergency2013$vstctgry) currentDataset <- read.csv(paste0('./data/', input$dataSetInput, sep=''))
plot(currentDataset$duid, currentDataset$vstctgry)
}) })
output$mytable1 <- renderDataTable({ 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({ 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({ output$myplot <- renderPlot({
currentDataset <- read.csv(paste0('./data/', input$dataSetInput, sep=''))
library(ggplot2) library(ggplot2)
library(corrplot) 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]
}) })
}) })

View File

@ -5,11 +5,13 @@ shinyUI(fluidPage(
# Application title # Application title
titlePanel("Hello Shiny!"), titlePanel("Hello Shiny!"),
# Sidebar with a slider input for the number of bins # Sidebar with a slider input for the number of bins
sidebarLayout( sidebarLayout(
sidebarPanel( 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 # Show a summary table of the selected variables
mainPanel( mainPanel(
tabsetPanel( tabsetPanel(
@ -20,4 +22,4 @@ shinyUI(fluidPage(
) )
) )
) )
) )