title: How to have ggplot grouped bar graph showing percentages according to each group in R?
body: <p>I have a df with a variable a that contains two strings "stringA1" and "stringA2". It also has a variable b that contains three strings "StringB1", "stringB2" and "stringB3".</p>
  
  <p>What I need is a graph grouped by variable b and showing the percentage of "stringA1" and "stringA2" within each group. </p>
  
  <p>I followed the advice posted on the link below: <a href="https://sebastiansauer.github.io/percentage_plot_ggplot2_V2/" rel="nofollow noreferrer">https://sebastiansauer.github.io/percentage_plot_ggplot2_V2/</a></p>
  
  <p>And translated to fit my data:   </p>
  
  <pre><code>p &lt;- ggplot(STW, aes(x=STW$Q071_3, group=STW$Q01))+
     geom_bar(mapping = aes(y = ..prop.., fill = factor(..x..), x=STW$Q071_3),   
     stat="count")+
     scale_y_continuous(labels=scales::percent)+
     facet_grid(~Q01)+
  p  
  </code></pre>
  
  <p>This, however, gives me a graph with above 100% and I cannot find the error.</p>
  
  <p>I have tried to play around with <code>(..count..)/sum(..count..)</code>, but did not get any useful results. </p>
  
  <p>How can I solve this? Thank you and let me know if I should post more information - this is the first post I am making here and I hope to be concise and clear :)</p>
  
  <p>Thank you in advance!</p>