title: Dynamic variable names using SE mutate function
body: <p>I don't know how to cut dynamic variables into groups within a for loop.</p>
  
  <p><code>df</code> is the data frame that contains <code>clm_april</code> - <code>clm_sept</code> variables that are <code>double</code>. Also I would like to put different names for new columns.</p>
  
  <p>Groups which are different for every month looks like this:</p>
  
  <pre><code>&gt; groups_april
   [1] "0"       "500"     "1000"    "1500"    "2000"    "3500"   
   [7] "4500"    "5000"    "9500"    "2000000"
  </code></pre>
  
  <p>The following does not work:</p>
  
  <pre><code>vector &lt;- c("april", "may", "june", "july", "aug", "sept")
  
  for (i in vector) {
    varname &lt;- paste0("clm_", i)
    df &lt;- df %&gt;%
      mutate_(.dots = 
                cut(list(varname),
                    breaks = groups[i],
                    include.lowest = T,
                    dig.lab = 10))
  }
  </code></pre>
  
  <p>I have also tried:</p>
  
  <pre><code>for (i in vector) {
    varname &lt;- paste0("clm_", i)
    df &lt;- df %&gt;%
      mutate_(.dots = interp(~cut(list(varname),
                             breaks = groups[i],
                             include.lowest = T,
                             dig.lab = 10,  varname=as.name(varname))))
  }
  </code></pre>
  
  <p>R throws the following error:</p>
  
  <pre><code>Error in mutate_impl(.data, dots) : 
    Evaluation error: 'x' must be numeric.
  </code></pre>
  
  <p>Can you help me solve this problem?</p>
  
  <p>EDIT:</p>
  
  <pre><code># A tibble: 10 x 6
     clm_april clm_may clm_june clm_july clm_aug clm_sept
         &lt;dbl&gt;   &lt;dbl&gt;    &lt;dbl&gt;    &lt;dbl&gt;   &lt;dbl&gt;    &lt;dbl&gt;
   1         0       0        0        0     689        0
   2      2000       0     1000     1000    1000        0
   3      5000    1000     1000     1000    1500     1518
   4      1000    1069     1100     1200    2019     2000
   5       679     689     9000    10000   36681     2000
   6       800    1000     1000      657    1815     2500
  </code></pre>