title: stat_function conflict with loop in R
body: <p>I have a table called join_boin. and there is 4 column.</p>
  <pre><code>list &lt;- c(&quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;d)
  
  function &lt;- function(a){
    
    for (i in list){
      table %&gt;%
        ggplot(aes(!!as.name(i)))+
        geom_histogram(aes(y=amount)) +
    stat_function(fun = dnorm, args = list(mean = mean(table$a), sd = sd(table$a)))  -&gt; result
      
      print(result)
    }
  }
  
  </code></pre>
  <p>When I use a loop to create a distribution for 4 variable's histograms, I don't know how to deal with (mean = mean(table $ DIFFERENT VARIABLES) ...</p>