I am using fread() from data.table to efficiently read large rectangular CSV files into R which are all double (and only double) values -- no missing elements.
However if I have very very small numbers in scientific notation, it'll get converted to character which ruins the whole read. Here is the error message (as an example, there are multiple for each small number):
16: In fread("SomeCSVFile") :
Bumped column 560 to type character on data row 16799, field contains '-2.1412168512924677E-308'. Coercing previously read values in this column from integer or numeric back to character which may not be lossless; e.g., if '00' and '000' occurred before they will now be just '0', and there may be inconsistencies with treatment of ',,' and ',NA,' too (if they occurred in this column before the bump). If this matters please rerun and set 'colClasses' to 'character' for this column. Please note that column type detection uses the first 5 rows, the middle 5 rows and the last 5 rows, so hopefully this message should be very rare. If reporting to datatable-help, please rerun and include the output from verbose=TRUE.
I want the function to set them to zero or truncate them at the minimum possible value (either is fine).
matrix[is.character(matrix)]<-numeric(0)- Carl Witthoftcsvspawned from the vile pit of Excel. - Carl Witthoft