0

I'm on Win7 32bit, and I know this probably has something to do with some Windows limitation, but I don't really understand it. I was working with a column of 20-digit ID numbers in a dataframe, and my results weren't what I expected... several frustrating hours later I realized R had messed up my 20-digit ID numbers in a very subtle way:

Type a 16 digit number in R:

> 1234567890123456
[1] 1234567890123456

Looks pretty normal. Now try a 20 digit number:

> 12345678900123456789
[1] 12345678900123457536

Notice the last 4 digits, 6789, have now turned into 7536... No warning message or anything.

Luckily, I'm not doing any arithmetic with these numbers so I just re-read them in as characters and everything was fine. But I'd still like to understand why R behaves like this. Thanks.

winampman
  • 484
  • 5
  • 15
  • 1
    See here: http://stackoverflow.com/q/14589354/324364 – joran Feb 06 '14 at 18:36
  • @joran - I think this is different. this is a case of "Just because there are numerals, don't think it's a number". So, user2763105, since these are IDs, first turn them into character strings. You will never (I sure hope!) be performing math on them. – Carl Witthoft Feb 06 '14 at 19:45
  • @CarlWitthoft There are two distinct issues: one is why R is treating the numbers in this way, and the question I link to addresses that. The OP already said in their post that they solved their immediate problem by reading them as characters, which I agree, is the right way to deal with ID values. – joran Feb 06 '14 at 19:48

0 Answers0