title: dplyr mutate using dynamic variable name while respecting group_by
body: <p>I'm trying as per</p>
  
  <p><a href="https://stackoverflow.com/questions/49311043/dplyr-mutate-using-variable-columns">dplyr mutate using variable columns</a>
  &amp;
  <a href="https://stackoverflow.com/questions/26003574/dplyr-mutate-use-dynamic-variable-names">dplyr - mutate: use dynamic variable names</a></p>
  
  <p>to use dynamic names in mutate.  What I am trying to do is to normalize column data by groups subject to a minimum standard deviation.  Each column has a different minimum standard deviation</p>
  
  <p>e.g. (I omitted loops &amp; map statements for convenience)</p>
  
  <pre><code>require(dplyr)
  require(magrittr)
  data(iris)
  iris &lt;- tbl_df(iris)
  
  minsd &lt;- c('Sepal.Length' = 0.8)
  varname &lt;- 'Sepal.Length'
  
  iris %&gt;% group_by(Species) %&gt;% mutate(!!varname := mean(pluck(iris,varname),na.rm=T)/max(sd(pluck(iris,varname)),minsd[varname]))
  </code></pre>
  
  <p>I got the dynamic assignment &amp; variable selection to work as suggested by the reference answers.  But group_by() is not respected which, for me at least, is the main benefit of using dplyr here</p>
  
  <p>desired answer is given by</p>
  
  <pre><code>iris %&gt;% group_by(Species) %&gt;% mutate(!!varname := mean(Sepal.Length,na.rm=T)/max(sd(Sepal.Length),minsd[varname]))
  </code></pre>
  
  <p>Is there a way around this?</p>