-1

I'm trying to load some data using fread. While loading it shows the correct number of records, but when its finished loading, the no. of records are comparatively less.

Surprising it doesn't show any warnings. Please can someone advise? see attached pic click here

Thanks

  • 1
    It's not easy to say for sure without a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). Do you have blank lines? Character values with embed newlines? Improperly quoted values? Lines that are commented out? – MrFlick Jan 22 '18 at 20:05

1 Answers1

1

One common reason is un-clean data with inappropriat un-ended quotations.

E.g., if you have data like this:

number_column,text_column
1,text data 1
2,"text with single quote here
3,text data 3

EVERYTHING after the single quote will be included in the text_column on the 2nd line. This is actually the correct way to interpret, it's just that your CSV/TSV file is broken.

The easiest solution is to use quote="" as a parameter, but the real solution is to go through your TSV/CSV file and fix all the issues manually, since the interpreter cannot know exactly what you want if the file is broken.

thc
  • 9,527
  • 1
  • 24
  • 39