title: How to use dplyr's enquo and quo_name in a function with tidyr and ggplot2
body: <pre><code>library(dplyr) #Devel version, soon-to-be-released 0.6.0
  library(tidyr)
  library(ggplot2)
  library(forcats) #for gss_cat data
  </code></pre>
  
  <p>I'm attempting to write a function that combines quosures from the soon-to-be-released <code>dplyr</code> devel version together with <code>tidyr::gather</code> and <code>ggplot2</code>. So far it seems to work with <code>tidyr</code>, but I'm having trouble with the plotting. </p>
  
  <p>The below function seems to work with <code>tidyr's gather</code>: </p>
  
  <pre><code>GatherFun&lt;-function(gath){
    gath&lt;-enquo(gath)
  
    gss_cat%&gt;%select(relig,marital,race,partyid)%&gt;%
      gather(key,value,-!!gath)%&gt;%
      count(!!gath,key,value)%&gt;%
      mutate(perc=n/sum(n))
  }
  </code></pre>
  
  <p>But I can't figure out how to make the plots work. I tried using <code>!!gath</code> with <code>ggplot2</code>, but it didn't work. </p>
  
  <pre><code>GatherFun&lt;-function(gath){
    gath&lt;-enquo(gath)
  
    gss_cat%&gt;%select(relig,marital,race,partyid)%&gt;%
      gather(key,value,-!!gath)%&gt;%
      count(!!gath,key,value)%&gt;%
      mutate(perc=n/sum(n))%&gt;%
      ggplot(aes(x=value,y=perc,fill=!!gath))+
         geom_col()+
         facet_wrap(~key, scales = "free") +
         geom_text(aes(x = "value", y = "perc", 
                       label = "perc", group = !!gath),
                   position = position_stack(vjust = .05))
  }
  </code></pre>