title: How to add text in the stacked barplot using ggplot2 package of R?
body: <p>I am analyzing a 5 point - Likert scale questionnaire and trying to visualize a stacked bar plot using ggplot2 of R.</p>
  <p>The dataset could be found in this link - <a href="https://gofile.io/d/fKVZuL" rel="nofollow noreferrer">https://gofile.io/d/fKVZuL</a></p>
  <p>The dataset of mine is in a .sav (SPSS) format.</p>
  <p>So I am following codes to read this data:</p>
  <pre><code>require(&quot;foreign&quot;)
  d = read.spss(file.choose(), to.data.frame=TRUE)
  attach(d)
  </code></pre>
  <p>Now to plot this 5-point Likert scale into stacked bar plot I have used <code>tidyverse</code> package that includes <code>ggplot2</code></p>
  <pre><code>require(&quot;tidyverse&quot;)
  d %&gt;% select(F1:F6) %&gt;% na.omit %&gt;% nrow
  d %&gt;% select(F1:F6) %&gt;% na.omit -&gt; f_items
  f_items %&gt;% gather(key = items, value = answer) %&gt;% mutate(answer = factor(answer),items = factor(items)) -&gt; data2
  </code></pre>
  <p>To rearrange the keys of the legend I have used the following codes:</p>
  <pre><code>data2$answer = factor(data2$answer, levels = c(&quot;Strongly Agree&quot;, &quot;Agree&quot;, &quot;Neutral&quot;,
                                             &quot;Disagree&quot;, &quot;Strongly Disagree&quot;))
  </code></pre>
  <p>Then I created the stacked bar plot using the following codes:</p>
  <pre><code>ggplot(data2, aes(x = items)) +
  geom_bar(aes(fill = answer), position = &quot;fill&quot;) +
  coord_flip() +
  scale_x_discrete(limits = rev(levels(data2$items)))+
  scale_y_continuous(labels = scales::percent)+
  scale_fill_brewer(palette=&quot;RdYlBu&quot;)-&gt; p2
  p2
  </code></pre>
  <p>These codes produces this figure:
  <a href="https://i.stack.imgur.com/HmH8s.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HmH8s.png" alt="enter image description here" /></a></p>
  <p>Now I want to add the percentage of each of the questions responses like this figure but could not be able to manage the codes:
  <a href="https://i.stack.imgur.com/i84he.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/i84he.png" alt="enter image description here" /></a></p>
  <p>How can I add the percentage of the questions responses like this figure? It would be a great help to me.</p>
  <p>-Shakil</p>