Here is an example working example with a drop-down list as an argument. The output of this program can be viewed at http://glimmer.rstudio.com/bishwamitrad/ggplot2browser/ :
ui.R
library(shiny) library(ggplot2)
server.R
library(shiny) library(ggplot2) ## Define server logic required to generate and plot a random distribution shinyServer(function(input,output) { dataset <- reactive(function(){ diamonds[sample(nrow(diamonds),input$sampleSize),] }) output$plot <- renderPlot(function(){ p <- ggplot(dataset(),aes_string(x=input$x, y=input$y))+geom_point() if(input$color != 'None') p <- p + aes_string(color=input$color) if (input$shape != 'None') p <- p + aes_string(shape=input$shape) 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() print(p) }) })
source share