title: Creating a Stacked Percentage Bar Chart in R with ggplot
body: <p>I have been looking for a way to be able to show the stacked bar chart responses as percentage values, according to the gender classification of the respondents. </p>
  
  <p>I was successful in creating a stacked bar plot using the variable 'sex' for the fill, but I want the plot to show the proportion between this variable. I know that using (..count..)/sum(..count) and  scale_y can change the y axis so that it shows the percentages, but I can't find a way to use it for what I want. Manually doing a separate data frame with the frequency values [edit] reflecting the percentages is also possible, but I am really keen on looking for a way to use only ggplot.</p>
  
  <p><a href="http://i.stack.imgur.com/VnEEP.png" rel="nofollow">This is what the plot currently looks like:</a></p>
  
  <p>This is the current code:</p>
  
  <pre><code>workday&lt;-ggplot(student,aes(x=Dalc2,fill=sex))
  plot1&lt;-workday+geom_bar()+facet_wrap(~romantic2)+labs(title="Workday Alcohol Consumption",y="Number of Respondents",x="Response")+ylim(0,300)
  </code></pre>
  
  <p>I know it's a pretty basic problem, but any enlightenment on this one would be greatly appreciated.</p>
  
  <p>(Data set from uci.edu)</p>
  
  <p>EDIT:</p>
  
  <p>For those interested in the solution, r.bot (lots of thanks!) suggested using     <code>geom_bar(position="fill")</code></p>
  
  <p>Also adding this to modify the y-axis:
      <code>scale_y_continuous(labels=percent)</code></p>
  
  <p><a href="http://i.stack.imgur.com/tbV2a.png" rel="nofollow">This is what the final graph looks like</a></p>