I am trying to read a CSV file in R (under linux) using read.csv(). After the function gets completed I find that the number of lines read in R is less than the number of lines in CSV file (obtained by wc -l). Also, every time I read that specific CSV file always the same lines are getting skipped. I checked the formatting errors in CSV file but everything looks good.
But if I extract the lines being skipped into another CSV file, then R is able to read very lines from that file.
I am not able to find anywhere what my problem could be. Any help greatly appreciated.
Here’s an example of using
count.fieldsto determine where to look and perhaps apply fixes. You have a modest number of lines that are 23 ‘fields’ in width:I looked at the 23 with:
And they had octothorpes (“#”, hash-signs) which are comment characters in R data parlance.
So…. use those settings in
read.tableand you should be “good to go”.