title: boxplot in R, aesthetics must be either length 1 or the same length as data
body: <p>I'm doing some analysis on the auto miles per gallon data from UCI website:</p>
  
  <p><a href="https://archive.ics.uci.edu/ml/datasets/Auto+MPG" rel="nofollow noreferrer">https://archive.ics.uci.edu/ml/datasets/Auto+MPG</a></p>
  
  <p>I factored the first column into either high or low mileage:</p>
  
  <pre><code>mpg01 = I(auto1$mpg &gt;= median(auto1$mpg))
  Auto = data.frame(mpg01, auto1[,-1])
  head(Auto)
  
      mpg01 cylinders displacement horsepower weight acceleration year origin
   1 FALSE         8          307        130   3504         12.0   70      1
   2 FALSE         8          350        165   3693         11.5   70      1
   3 FALSE         8          318        150   3436         11.0   70      1
   4 FALSE         8          304        150   3433         12.0   70      1
   5 FALSE         8          302        140   3449         10.5   70      1
   6 FALSE         8          429        198   4341         10.0   70      1
  </code></pre>
  
  <p>Now I want to make boxplot for each of the columns from dataframe, factored by the first column.</p>
  
  <pre><code>vars &lt;- c("cylinders", "displacement", "horsepower", "weight", "acceleration", "year", "origin")
  ggplot(Auto) + geom_bar(aes(y=vars, fill=factor(mpg01)))
  </code></pre>
  
  <p>And I get the error "Aes must be either length 1 or the same as data"</p>
  
  <p>The dimension of "Auto" dataframe is 392x8</p>
  
  <p>I can just use boxplot for each column, but want to know if there's a way to combine them into one. Thanks!</p>