R Shiny selectInput that is dependent on another selectInput : <p>I have some data below that I'm using to create a donut chart in R shiny, where <code>date</code> is a character. I want to be able to select the email whose score I want to view, but then in the second dropdown selection only see the dates for which that email has activity.</p>

<p>For example, if I select email = xxxx in the first dropdown, I want to see only 'no activity' in the date selection field. And for email = yyyy, I want to see only 6/17/14, 6/18/14, 6/19/14 as selections. </p>

<p>I've tried a sort of nested subsetting in the ui. Example:</p>

<pre><code>&gt; ui &lt;- shinyUI(fluidPage(
+   sidebarLayout(
+     sidebarPanel(
+       selectInput('Select', 'Customer:', choices = unique(as.character(dat5$email))),
+       selectInput("User", "Date:", choices = dat5[dat5$email==input$Select,date])
+     ),
+     mainPanel(plotOutput("distPlot"))
+   )
+ ))
</code></pre>

<p>But this still shows all possible date selections</p>

<p><strong>DATA</strong></p>

<pre><code>email   date        variable    value   ymin    ymax
xxxx    no activity e_score         0   0       0
xxxx    no activity diff            1   0       1
yyyy    6/17/14     e_score    0.7472   0       0.7472
yyyy    6/17/14     diff       0.2528   0.7472  1
yyyy    6/18/14     e_score    0.373    0       0.373
yyyy    6/18/14     diff       0.627    0.373   1
yyyy    6/19/14     e_score    0.533    0       0.533
yyyy    6/19/14     diff       0.467    0.533   1
</code></pre>

<p>My code so far:</p>

<p><strong>app.R</strong></p>

<pre><code>library(shiny)
library(shinydashboard)

ui &lt;- shinyUI(fluidPage(
  sidebarLayout(
    sidebarPanel(
      selectInput('Select', 'Customer:', choices = unique(as.character(dat5$email))),
      selectInput("User", "Date:", choices = unique(dat5$date) )
    ),
    mainPanel(plotOutput("distPlot"))
  )
))


server &lt;- function(input, output) {
  output$distPlot &lt;- renderPlot({
    ggplot(data = subset(dat5, (email %in% input$Select &amp; date %in% input$User)), aes(fill=variable, ymax = ymax, ymin = ymin, xmax = 4, xmin = 3)) +
      geom_rect(colour = "grey30", show_guide = F) +
      coord_polar(theta = "y") +
      geom_text(aes(x = 0, y = 0,label = round(value[1]*100))) +
      xlim(c(0, 4)) +
      theme_bw() +
      theme(panel.grid=element_blank()) +
      theme(axis.text=element_blank()) +
      theme(axis.ticks=element_blank()) +
      xlab("") +
      ylab("") +
      scale_fill_manual(values=c('#33FF00','#CCCCCC')) 

  })
}
  shinyApp(ui = ui, server = server)
</code></pre>
