title: RStudio Shiny Conditional Plot
body: <p>Im trying to create a web application with the new RStudio feature Shiny, which plots different stocks. I created the following example. </p>
  
  <p>I want to select the dataset StockMarket then select eg the DAX and then finally the plot should appear. </p>
  
  <p>Right now if you run this code the plot appears immediately</p>
  
  <p>Could you help me please?</p>
  
  <pre><code>ui.R:
  library(shiny)
  library(ggplot2)
  
  shinyUI(pageWithSidebar(
  
  # Application title
  headerPanel("Plot1"),
  sidebarPanel(
  selectInput("dataset", "Dataset", list("mtcars"="cars", "StockMarket"="stocks")),
  
  conditionalPanel(
    condition = "input.dataset=='stocks'",
    uiOutput("data")
  )),
  mainPanel(
  plotOutput('plotstock')) ))
  
  
  server.R:
  library(shiny)
  require(ggplot2)
  library(datasets)
  
  shinyServer(function(input, output) {
  
  output$data&lt;- reactiveUI(function() {
  
  selectInput("data", "Choose Dataset", colnames(EuStockMarkets))
  })
  
  output$plotstock &lt;- reactivePlot(function() {
  data&lt;-data.frame(EuStockMarkets)
  p&lt;- ggplot(data,aes(x=seq(1,length(data[,1])),y=DAX))+geom_line(size=1)+ylab("")+opts(title="Time Series")
  print(p)
   })})
  </code></pre>