title: Why am I getting X. in my column names when reading a data frame?
body: <p>I asked a <a href="https://stackoverflow.com/questions/9098245/r-why-are-xs-added-to-the-names-of-variables-in-my-data-frame">question about this a few months back</a>, and I thought the answer had solved my problem, but I ran into the problem again and the solution didn't work for me.  </p>
  
  <p>I'm importing a CSV:</p>
  
  <pre><code>orders &lt;- read.csv("&lt;file_location&gt;", sep=",", header=T, check.names = FALSE)
  </code></pre>
  
  <p>Here's the structure of the dataframe:</p>
  
  <pre><code>str(orders)
  
  'data.frame':   3331575 obs. of  2 variables:
   $ OrderID  : num  -2034590217 -2034590216 -2031892773 -2031892767 -2021008573 ...
   $ OrderDate: Factor w/ 402 levels "2010-10-01","2010-10-04",..: 263 263 269 268 301 300 300 300 300 300 ...
  </code></pre>
  
  <p>If I run the <code>length</code> command on the first column, OrderID, I get this:</p>
  
  <pre><code>length(orders$OrderID)
  [1] 0
  </code></pre>
  
  <p>If I run the <code>length</code> on OrderDate, it returns correctly:</p>
  
  <pre><code>length(orders$OrderDate)
  [1] 3331575
  </code></pre>
  
  <p>This is a copy/paste of the <code>head</code> of the <code>CSV</code>.  </p>
  
  <pre><code>OrderID,OrderDate
  -2034590217,2011-10-14
  -2034590216,2011-10-14
  -2031892773,2011-10-24
  -2031892767,2011-10-21
  -2021008573,2011-12-08
  -2021008572,2011-12-07
  -2021008571,2011-12-07
  -2021008570,2011-12-07
  -2021008569,2011-12-07
  </code></pre>
  
  <p>Now, if I re-run the <code>read.csv</code>, but take out the <code>check.names</code> option, the first column of the <code>dataframe</code> now has an X. at the start of the name.  </p>
  
  <pre><code>orders2 &lt;- read.csv("&lt;file_location&gt;", sep=",", header=T)
  
  str(orders2)
  
  'data.frame':   3331575 obs. of  2 variables:
   $ X.OrderID: num  -2034590217 -2034590216 -2031892773 -2031892767 -2021008573 ...
   $ OrderDate: Factor w/ 402 levels "2010-10-01","2010-10-04",..: 263 263 269 268 301 300 300 300 300 300 ...
  
  length(orders$X.OrderID)
  [1] 3331575
  </code></pre>
  
  <p>This works correctly.  </p>
  
  <p>My question is why does <code>R</code> add an X. to beginning of the first column name?  As you can see from the CSV file, there are no special characters. It should be a simple load.  Adding <code>check.names</code>, while will import the name from the CSV, will cause the data to not load correctly for me to perform analysis on.  </p>
  
  <p>What can I do to fix this?</p>
  
  <p>Side note:  I realize this is a minor - I'm just more frustrated by the fact that I think I am loading correctly, yet not getting the result I expected.  I could rename the column using <code>colnames(orders)[1] &lt;- "OrderID"</code>, but still want to know why it doesn't load correctly.  </p>