title: R using Merge: "id variables not found in data:"
body: <p>My data has a structure as follows:</p>
  
  <pre><code>&lt;ID&gt; &lt;Gender&gt; &lt;Age&gt; &lt;St&gt; &lt;Ep1&gt; &lt;Ep2&gt; &lt;Ep3&gt; &lt;Ep...&gt;
  </code></pre>
  
  <p>Meaning, the number of <code>Ep#</code> columns is bound to change and to be quite large. Now what I'm trying to achieve, is to see if there is a difference in their distribution based on gender. Each <code>Ep#</code> column at this point, simply contains the amount of observations - to simplify the data frame - per <code>Ep</code>. In order to do so, I looked at the <code>reshape2</code> package, and before melting the data, I extracted the <code>&lt;Ep#&gt;</code> column names, onto a variable named <code>columnNames</code>.</p>
  
  <pre><code>maleFrame &lt;- melt((columnNames),(simpleFrame[simpleFrame$`Gender (Binary)` == 1,])[, -2], 
                    id.vars="columnNames", measure.vars="Idade", "`Gender (Binary)`")
  </code></pre>
  
  <p>Unfortunately this yields an error:</p>
  
  <pre><code>Error: id variables not found in data: columnNames
  </code></pre>
  
  <p>Upon reading some threads, it seems the problem is the <code>columnNames</code> must be character or integer types, and as of right now, they seem to be levels. However, when I try to convert them to integer using <code>as.numeric(as.character(columnNames))</code> or other methods, they all return a vector of 1's, when in reality, they should parse the true value, such as <code>90010001</code>. In fact, using <code>head(columnNames)</code> yields (I cut the result as its quite large):</p>
  
  <pre><code>&gt; V9      V11      V13      V15      V17      V19      V21      V23      V25      V27      V29      V31      V33      V35      V37      V39
  1 90009901 90009902 90009911 90009999 90010001 90010002 90010003 90010004 90010005 90010006 90010007 90010008 90019901 90020003 90020004 90020005
  </code></pre>
  
  <p>Any ideas?</p>