title: How can I add the ratio on the bars in a stacked bar
body: <p>I would like to add the ratio between the value counts of a stacked bar plot above the bars, how can I do it?
  here is the example data frame:</p>
  
  <pre><code>dat &lt;- read.table(text = " TargetVar  Var1    Var2       Var3
   0        0        0         7
   0        0        1         1
   0        1        0         3
   0        1        1         7
   1        0        0         5
   1        0        1         1
   1        1        0         0
   1        1        1         6
   0        0        0         8
   0        0        1         5
   1        1        1         4
   0        0        1         2
   1        0        0         9
   1        1        1         2  ", header = TRUE)
  </code></pre>
  
  <p>I wrote the following code:</p>
  
  <pre><code>counts &lt;- table(dat$TargetVar, dat$Var3)
  barplot(counts, main="Is churn",
          xlab="Var1", col=c("darkblue","red"),
          legend = rownames(counts))
  </code></pre>
  
  <p>and got this chart, but how can I add the ratio above the bars?</p>
  
  <p><img src="https://i.stack.imgur.com/3c66A.png" alt="bar chart"></p>