title: Error: stat_summary requires the following missing aesthetics: y
body: <p>I'm trying to create a <code>barplot</code> with confidence interval error bars using <code>ggplot</code>. Essentially, I have a variable, <code>Q1</code>, with 7 answer options, and I want to plot the percent of respondents for each option, as a factor of two groups (One and Two) - the percent of subjects in each group that selected each of the 7 answer option. </p>
  
  <p>I've tried adding <code>y= count</code>, <code>y=prop</code> or <code>y=..prop..</code> to <code>aes</code> in <code>ggplot</code>, but it neither seem to work. Any suggestions are appreciated.</p>
  
  <pre><code>df5 &lt;- filter(df, Q1!="-99",df$Group=="One"|df$Group=="Two") 
  
  ggplot(data = df5, aes(x = Q1)) + 
   stat_summary(fun.y = mean, geom = "bar") +
   stat_summary(fun.data = mean_cl_boot, geom = "errorbar", fun.args = list(mult = 1)) +
      geom_bar(aes(label= scales::percent(..prop..),
                     y= ..prop..,fill = df5$Group), position = "dodge")
  </code></pre>
  
  <blockquote>
    <p>Error: stat_summary requires the following missing aesthetics: y.</p>
  </blockquote>
  
  <p>I'm essentially trying to get something that looks like this, with the error bars representing confidence intervals.</p>
  
  <p><a href="https://i.stack.imgur.com/8babn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8babn.png" alt="example of barplot with error bars."></a></p>