title: Error calculating mean by input variable in Shiny
body: <p>Using the mtcars dataset in R, I am tying to use the input variable (cyl, am etc...) to calculate the mean mpg by that variable.</p>
  
  <p>My code in the ui.R is like:</p>
  
  <pre><code>verbatimTextOutput("Avg_Mileage")
  </code></pre>
  
  <p>My code in the shinServer function in server.R is like:</p>
  
  <pre><code>carsdata &lt;- mtcars
  
  output$Avg_Mileage &lt;- renderPrint({aggregate(mpg~input$variable, carsdata,mean)})
  </code></pre>
  
  <p>I have tried to change the code in server.R in various ways. But I keep getting the message about conflicting variable lengths: <strong>"variable lengths differ (found for 'input$variable')</strong>"</p>
  
  <p>I would appreciate any help in trying to see how can this mean mpg by input variable be implemented in Shiny</p>