title: R is duplicating large integers when reading in a data frame
body: <p>I have a database table with a column containing distinct 17 digit numbers. When I ask R to read a section or all of this table into a dataframe it duplicates some of the values 4 or 5 times and drops others. The effect is that a table with say 17 unique values will end up with 6. This is bizarre. It's happening when I read in the data using the RODBC connection or whether I save them to a csv and load them that way.  It's definitely an R problem because I've isolated the issue with fake data:</p>
  
  <pre><code>base_num &lt;- "9600000005206"
  
  # Now create a vector of unique numbers in character format
  x &lt;- paste0(base_num, seq(5680, 5760, 1))
  
  x
  
  x
  [1] "96000000052065680" "96000000052065681" "96000000052065682" 
  "96000000052065683" "96000000052065684" "96000000052065685" 
  "96000000052065686"
  [8] "96000000052065687" "96000000052065688" "96000000052065689" 
  "96000000052065690" "96000000052065691" "96000000052065692" 
  "96000000052065693"
  [15] "96000000052065694" "96000000052065695" "96000000052065696" 
  "96000000052065697" "96000000052065698" "96000000052065699" 
  "96000000052065700"
  
  # Convert them to numeric
  # ta-da! Duplicate values and dropped values
  as.numeric(x)
  
   [1] 96000000052065680 96000000052065680 96000000052065680 
   96000000052065680 96000000052065680 96000000052065680 96000000052065680
   [8] 96000000052065680 96000000052065696 96000000052065696 
   96000000052065696 96000000052065696 96000000052065696 96000000052065696
   [15] 96000000052065696 96000000052065696 96000000052065696 
   96000000052065696 96000000052065696 96000000052065696 96000000052065696
  </code></pre>
  
  <p>This is what's happening when I read from the database or a CSV where I know the column contains unique values. Thanks.</p>
  
  <p>EDIT:</p>
  
  <p>Thanks for highlighting the problem and how to fix it in R. The problem is still that R is completing this transformation while reading in the data. Even if I specify my query as:</p>
  
  <pre><code>CAST(longnumber AS VARCHAR(50)) as 'target_column'
  </code></pre>
  
  <p>R <em>still</em> treats it as a too-long integer. I have to write:</p>
  
  <pre><code>CAST(longnumber AS VARCHAR(50)) + 'S' as 'target_column'
  </code></pre>
  
  <p>in order to get R to read it in as a character field which is all I need. Any ideas?</p>