# # This is a Shiny web application. You can run the application by clicking # the 'Run App' button above. # # Find out more about building applications with Shiny here: # # http://shiny.rstudio.com/ # library(shiny) library (ggplot2) dataset_all <- knime.in colnames (dataset_all) <- make.names(colnames(dataset_all), unique = TRUE) # Define UI for application that draws a histogram ui <- fluidPage(title = "Data Explorer", plotOutput('plot'), hr(), fluidRow( column( 3, h4("Data Explorer"), sliderInput( 'sampleSize', 'Sample Size', min = 1, max = nrow(dataset_all), value = min(1000, nrow(dataset_all)), step = 500, round = 0 ), br(), checkboxInput('jitter', 'Jitter'), checkboxInput('smooth', 'Smooth'), sliderInput ('base_size', label = "Size", value = 16, min = 10, max = 32, step = 1) ), column( 4, offset = 1, selectInput('x', 'X', names(dataset_all)), selectInput('y', 'Y', names(dataset_all), names(dataset_all)[[2]]), selectInput('color', 'Color', c('None', names(dataset_all))) ), column( 4, selectInput('facet_row', 'Facet Row', c(None = '.', names(dataset_all[sapply(dataset_all, is.factor)]))), selectInput('facet_col', 'Facet Column', c(None = '.', names(dataset_all[sapply(dataset_all, is.factor)]))) ) )) # Define server logic required to draw a histogram server <- function(input, output) { dataset <- reactive({ dataset_all[sample(nrow(dataset_all), input$sampleSize), ] }) output$plot <- renderPlot({ p <- ggplot(dataset(), aes_string(x = input$x, y = input$y)) + geom_point() if (input$color != 'None') p <- p + aes_string(color = input$color) facets <- paste(input$facet_row, '~', input$facet_col) if (facets != '. ~ .') p <- p + facet_grid(facets) if (input$jitter) p <- p + geom_jitter() if (input$smooth) p <- p + geom_smooth() p <- p + theme_bw(base_size = input$base_size) print(p) }) } # Run the application shinyApp(ui = ui, server = server)