title: How can I visualize the diffrent time intervals by choosing the diffrent modes of transport in my Shiny bar plot?
body: <p>How can I make my Barchart interactive? I want to see the arrival time by choosing the different modes of transport. I am able to run the app, however, it is impossible to make it interactive.</p>
  <p>The variable <code>Arrival</code> are time intervals.
  The variable <code>Mode</code> are modes of transport.
  The variable <code>Answer</code> means Yes/No.</p>
  <p>This is a part of my dataframe:</p>
  <pre><code>&gt; head(Data_Long)
      Id               Arrival    Mode Answer
  1   54 6:00 p.m. - 6:30 p.m. On foot    Yes
  2  132 5:30 p.m. - 6:00 p.m. On foot    Yes
  3  600 5:00 p.m. - 5:30 p.m. On foot    Yes
  4  620 4:00 p.m. - 5:00 p.m. On foot    Yes
  5  951 5:30 p.m. - 6:00 p.m. On foot    Yes
  6 1011 4:00 p.m. - 5:00 p.m. On foot    Yes
  </code></pre>
  <p>This is my code:</p>
  <pre><code>library(shiny)
  library(ggplot2)
  library(dplyr)
  library(tidyverse)
  library(readxl)
  
  #Read in Excel
  Survey &lt;- read_excel(&quot;04_Participant.xlsx&quot;)
  
  Data &lt;- subset(Survey, select = c(1, 4:14))
  
  colnames(Data) &lt;- c(
    'Id',
    'Arrival',
    'On foot',
    'Bicycle',
    'Bicycle (Yélo)',
    'Motorcycle/scooter',
    'Scooter (trotinette)',
    'Bus',
    'Train',
    'Car',
    'Carpool',
    'Car (Yélo)'
  )
  
  
  Data_Long &lt;- Data %&gt;% 
    gather(key=&quot;Mode&quot;,
           value = &quot;Answer&quot;,
           c(-Id, -`Arrival`))
  
  Data_Long &lt;- subset(Data_Long, Answer==&quot;Yes&quot;)
  
  Data_Long &lt;- as.data.frame(Data_Long)
  
  Data_Long %&gt;% 
    ggplot(aes(x=Arrival))+
    geom_histogram(stat=&quot;count&quot;)
  
  
  # ui.R ----
  ui &lt;- fluidPage(
    titlePanel(&quot;Arrival times&quot;),  # Add a title panel
    sidebarLayout(  
      position = &quot;right&quot;,
                    
      sidebarPanel(h3(&quot;Inputs for histogram&quot;),
                   selectInput(&quot;Mode&quot;, &quot;Select mode&quot;, choices = c(&quot;On foot&quot;=&quot;On foot&quot;,
                                                                  &quot;Bicycle&quot; = &quot;Bicycle&quot;,
                                                                  &quot;Bicycle (Yélo)&quot;=&quot;Bicycle (Yélo)&quot;,
                                                                  &quot;Motorcycle/scooter&quot;=&quot;Motorcycle/scooter&quot;,
                                                                  &quot;Scooter (trotinette)&quot;=&quot;Scooter (trotinette)&quot;,
                                                                  &quot;Bus&quot;=&quot;Bus&quot;,
                                                                  &quot;Train&quot; = &quot;Train&quot;,
                                                                  &quot;Car&quot; = &quot;Car&quot;,
                                                                  &quot;Carpool&quot;=&quot;Carpool&quot;,
                                                                  &quot;Car (Yélo)&quot;= &quot;Car (Yélo)&quot;),
                                                                    selected = &quot;Car&quot;),
                   br(),
                   
                   
                   ),
      
      # Inside the sidebarLayout, add a sidebarPanel
      mainPanel(
        plotOutput(&quot;myhist&quot;)
        #tableOutput(&quot;mytable&quot;),
        #textOutput(&quot;mytext&quot;)
        
      )  
    )
  )
  
  # server.R ----
  server &lt;- function(input, output) {
    
    output$myhist &lt;- renderPlot(
    
      Data_Long %&gt;% 
        ggplot(aes(x=Arrival))
      + geom_histogram(stat=&quot;count&quot;,group=input$Mode, data = Data_Long[Data_Long$Mode==input$Mode])
      
  
    )
    
  }
  
  # Run the app ----
  shinyApp(ui = ui, server = server)
  </code></pre>
  <p>I get the following error message:</p>
  <pre><code>Warning: Error in [.data.frame: undefined columns selected
    [No stack trace available]
  </code></pre>
  <p>This is a picture of the shiny app when I run it:
  <a href="https://i.stack.imgur.com/bprpK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bprpK.png" alt="Shiny app" /></a></p>