title: How to supply variable names as strings in fct_reorder within ggplot code?
body: <p>I want to create the geom_col chart by supplying the variable names as strings. I know the aes_string does that in the ggplot code. However, I am not sure how to handle the variables supplied in the fct_reorder to order the bars. Here is my wip code.</p>
  <p>I want to convert this:</p>
  <pre><code>mpg %&gt;% 
    ggplot() + 
    geom_col(aes(x = cty, y = fct_reorder(drv, cty, .fun = mean, na.rm = T), fill = drv), width = 0.8) +
    theme_classic()
  </code></pre>
  <p>into a function,</p>
  <pre><code>chart_fun &lt;- function(x, y) {
    mpg %&gt;%
      ggplot() +
      geom_col(aes_string(x = x, y = fct_reorder(y, x, .fun = mean, na.rm = T), fill = y), width = 0.8) +
      theme_classic()
  }
  
  chart_fun(x = &quot;cty&quot;, y = &quot;drv&quot;)
  </code></pre>
  <p>but I am getting an error, &quot;Error: 1 components of <code>...</code> were not used. We detected these problematic arguments: * <code>na.rm</code> Did you misspecify an argument?&quot;</p>
  <p>How can I fix this code?</p>