title: ggplot2 Stacked Bar Chart - Each Bar being 100% and with percenage labels inside each bar
body: <p><strong>Background:</strong> I am new to R and ggplot2 and hope to get a simple answer that benefits others in the same situation.</p>
  
  <p><strong>Question:</strong> What is a simple way in ggplot2 to make <strong>each bar add</strong> up to 100% and displaying <strong>percentage labels</strong> inside each bar?</p>
  
  <p><strong>Goal:</strong> <a href="https://i.stack.imgur.com/JWTpX.png" rel="noreferrer">What I want it to look like</a> (each column totals 100%, with percentage labels inside each column).</p>
  
  <p><strong>Current Chart:</strong> This is the bar chart I have so far; based on the "mtcars" dataset (<a href="https://i.stack.imgur.com/pxuC1.png" rel="noreferrer">What it currently looks like</a>).
  Below I have for the "Current Chart":</p>
  
  <pre><code>library(ggplot2) # loads ggplot2
  data &lt;- mtcars # gets the mtcars dataset
  
  #INFO: A simple barchart with X-axis being Nr of Cylinders, fill color indicating whether or not the car model has an Automatic gearbox..
  # ..and Y-axis showing the count of cars by Nr of Cylinders
  ggplot(mtcars, aes(x=cyl, fill = factor(am))) +
    geom_bar() +
    stat_count(geom = "text", 
               aes(label = paste(round((..count..)/sum(..count..)*100), "%")), # This row calculates the percentage across all data, adding up to 100%, but I want it to add up to 100% per X-variable (Nr of Cylinders = 4, 6, 8)
               position=position_stack(vjust=0.5), colour="white") # This row positions the bar percentage level and colors it white.
  </code></pre>
  
  <p>Many thanks in advance!</p>