title: Unable to do homog.test in a loop
body: <p>I have a problem looping through columns with this command. When printing &quot;i&quot;, the variable name appears, but it does not substitute it in the formula. The error suggested that I can't use a variable. Any suggestions?</p>
  <pre><code>for (i in colnames(NMDStrokeHx)[3:14]){
    print(i)
    print(homog.test(i ~ AM25, data = NMDStrokeHx, method = &quot;Levene&quot;))
  }
  </code></pre>
  <p>output:
  [1] &quot;ANCOWATO&quot;
  Error in homog.test(i ~ AM25, data = NMDStrokeHx, method = &quot;Levene&quot;) :
  The name of response variable does not match the variable names in the data.</p>
  <pre><code>these are the column names of the data:
  &gt; colnames(NMDStrokeHx)[3:14]
   [1] &quot;ANCOWATO&quot; &quot;ANMSETOT&quot; &quot;ANAFTOT&quot;  &quot;ANBNTTOT&quot; &quot;ANDELCOR&quot; &quot;ANWM2TOT&quot; &quot;ANFULVR1&quot; &quot;ANVRTCOR&quot; &quot;ANTMASEC&quot;
  [10] &quot;ANTMBSEC&quot; &quot;ANSDMTOT&quot; &quot;ADCDRSTG&quot;
  </code></pre>