title: dplyr() and ggolot2()::geom_tile, filtering a group of summary statistics
body: <p>I've got a data frame (df) with three categorical variables called site, purchase, and happycustomer.</p>
  
  <p>I'd like to use gglot2's geom_tile function to create a heat-map of customer experience. I'd like site on the x-axis, purchase on the y-axis, and happycustomer as the fill. I'd like the heat map to feature the percentages for the happy customers grouped by site and purchase (ie the ones for which the value of happycustomer is y). </p>
  
  <p>My problem's that at the moment the plot features both the happy and the unhappy customers.    </p>
  
  <p>Any help would be much appreciated. </p>
  
  <p>Starting point (df):</p>
  
  <pre><code>df &lt;- data.frame(site=c("GA","NY","BO","NY","BO","NY","BO","NY","BO","GA","NY","GA","NY","NY","NY"),purchase=c("a1","a2","a1","a1","a3","a1","a1","a3","a1","a2","a1","a2","a1","a2","a1"),happycustomer=c("n","y","n","y","y","y","n","y","n","y","y","y","n","y","n"))
  </code></pre>
  
  <p>Current code:</p>
  
  <pre><code>library(ggplot2) 
  library(dplyr)
  df  %&gt;% 
        group_by(site, purchase,happycustomer) %&gt;% 
        summarize(bin = sum(happycustomer==happycustomer)) %&gt;%
        group_by(site,happycustomer) %&gt;%
        mutate(bin_per = (bin/sum(bin)*100)) %&gt;%
        ggplot(aes(site,purchase)) + geom_tile(aes(fill = bin_per),colour = "white") + geom_text(aes(label = round(bin_per, 1))) +
        scale_fill_gradient(low = "blue", high = "red")
  </code></pre>