In R, read_csv() parsing failures: Converting integers into NA's

Mars Chen picture Mars Chen · Jul 14, 2017 · Viewed 11.3k times · Source

I just meet a problem when I use read_csv() and read.csv() to import CSV files into R. My file contains 1.7 million rows and 78 variables.Most of those variable are integers. When I use the read_csv(), some cells, which are integers, are converted into NA's and I get the following warnings. However, those cells are also integers so that I do not know why it goes wrong.

10487 parsing failures.
row col   expected      actual                                              
3507 X27 an integer 2946793000  
3507 X46 an integer 5246675000  
3508 X8  an integer 11599000000 
3508 X23 an integer 2185000000  
3508 X26 an integer 2185000000.

When I access df[3507,27], it just shows NA. Also, X27,X46 and X8 are all integers so that I do not understand why the function works for most rows but does not work in those several rows.

However, when I use read.csv(). It works and returns 2946793000. Can someone tell me why these two functions behave differently here?

Answer

G5W picture G5W · Jul 14, 2017

These numbers are too big to fit into an integer.

.Machine$integer.max
[1] 2147483647