title: How to refer to a tibble column, using a variable name, in a pipe (R)
body: <p>I am pretty new to R, so this question may be a bit naive.</p>
  
  <p>I have got a tibble with several columns, and I want to create a factor (Bin) by binning the values in one of the columns in N bins. Which is done in a pipe. However, I would like to be able to define the column to be binned at the top of the script (e.g. bin2use = RT), because I want this to be flexible.</p>
  
  <p>I've tried several ways of referring to a column name using this variable, but I cannot get it to work. Amongst others I have tried get(), eval(), [[]]</p>
  
  <h1>simplified example code</h1>
  
  <pre><code>Subject &lt;- c(rep(1,100), rep(2,100))
  RT &lt;- runif(200, 300, 800 )
  data_st &lt;- tibble(Subject, RT)
  
  bin2use = 'RT'
  nbin = 5
  
  binned_data &lt;- data_st %&gt;%
    group_by(Subject) %&gt;%
    mutate(
      Bin = cut_number(get(bin2use), nbin, label = F)
    )
  
  Error in mutate_impl(.data, dots) : 
    non-numeric argument to binary operator
  </code></pre>