title: Using column name when calling a function (cutpointr)
body: <p>I'm trying to perform a evaluation of optimal cutpoints on several pairs of variables/classes, using the <code>cutpointr</code> package (<a href="https://rdrr.io/cran/cutpointr/man/cutpointr.html" rel="nofollow noreferrer">https://rdrr.io/cran/cutpointr/man/cutpointr.html</a>). The documentations states that the syntax of the command is <code>cutpointr(data, x, class)</code>, with the former two being <code>variable names</code>.</p>
  <p>My dataframe looks like the following, with every ID having several variables A,B,... and corresponding binary classes for each variable.</p>
  <pre><code>ID   A   B   A_Class   B_Class
  1    7   5     1        0
  2    3   2     0        0
  3    6   3     0        1
  </code></pre>
  <p>I now want to perform the <code>cutpointr</code> operation for each of these pairs. I tried implementing a <code>for</code>-loop.</p>
  <pre><code>for (col in 2:3) {
    cutpoint &lt;- cutpointr(df, colnames(df[col]), colnames(df[col+2]))
    summary(cutpoint)
  }
  </code></pre>
  <p>This lead to the error <code>Error: Can't convert a call to a string</code>.</p>
  <p>When typing out the variable names like <code>cutpointr(df, A, A_Class)</code> there's no problem. Could someone point out what mistake I'm making here? Thanks a lot!</p>