title: Duplicate 'row.names' error reading table. row.names=NULL shifts columns
body: <p>This is similar to <a href="https://stackoverflow.com/questions/6595673/read-csv-row-names">read.csv row.names</a> and to <a href="https://stackoverflow.com/questions/12425599/duplicated-row-names">https://stackoverflow.com/questions/12425599/duplicated-row-names</a> , but I do not see answers that help.</p>
  
  <p>Problem: Trying to read in a file which contains duplicate numbers in first column, but shifts the column headers when row.names=NULL. </p>
  
  <p>I'm trying to read the following file into R</p>
  
  <pre><code>TripId  VID TspVID  VWT VCLS    Week
  
  201110041426    2226    33889   1   0   41
  
  201110041501    2226    33889   1   0   41
  
  201110041510    2226    33889   1   0   41
  
  201110041557    2226    33889   1   0   41
  </code></pre>
  
  <p>(this is a small excerpt from Excel of a CSV file with many thousands of rows and ~200 columns.  There are the same number of entries in the first row as in all others.  There are duplicates in the first row.  The columns don't line up with the labels in this view, but they do in CSV space.)</p>
  
  <p>The command</p>
  
  <pre><code>&gt; lm.table  &lt;- read.table(file= file.in, sep=",", header=TRUE)
  Error in read.table(file = file.in, sep = ",", header = TRUE) : 
    duplicate 'row.names' are not allowed
  </code></pre>
  
  <p>doesn't work.  Using the first column for row.names implies that the first row has less values than the others, which is not the case.  I certainly don't want the first column as row.names.</p>
  
  <p>I try to set row.names=NULL</p>
  
  <pre><code>&gt; lm.table  &lt;- read.table(file= file.in, sep=",", header=TRUE, row.names=NULL)
  </code></pre>
  
  <p>which runs, but the columns have been shifted</p>
  
  <pre><code>&gt; head(lm.table)
  
       row.names TripId   VID TspVID VWT VCLS       Week     Date TimeStart TimeEnd     Lat1
  
  1 201110010006   2226 33889      1   0   40 2011/09/30 17:06:37  17:25:16 47.5168 -122.209
  
  2 201110010028   2226 33889      1   0   40 2011/09/30 17:28:45  17:43:14 47.5517 -122.058
  
  3 201110010000   2231 45781      1   0   40 2011/09/30 17:00:00  18:02:30 32.9010 -117.193
  
  4 201110011407   2231 45781      1   0   40 2011/10/01 07:07:57  07:48:17 32.7044 -117.004
  </code></pre>
  
  <p>Note that the new column name "row.names has been introduced and the entire row shifted right.  </p>
  
  <p>Here is the tail end of the > head(lm.table) result.  It's shifted the column labels onto an undefined column (I think this also shows the number of column labels = number of columns, which is also true from inspection.)</p>
  
  <pre><code>      FVavR FVstdR FIdlR
  
  1  3.959140      2    NA
  
  2  5.285770     20    NA
  
  3  4.274140     26    NA
  </code></pre>
  
  <p>Any idea why I get the shifting in the columns and how to not shift and have the row.names simply be ascending numbers?</p>