read.csv stops reading at row 523924 even thouhg t

2019-08-31 06:10发布

问题:

Any idea why R would stop reading the file before it gets to the end?

I can open the file in excel, and it shows the full 799992. R reads only 65% of the file. I have saved the file as csv from Excel, but it did not change the number of rows R was able to read. In fact it stops reading at the exact same location every time.

I use the following command.

lem1 <- read.csv("lem1.csv", header=TRUE, sep =",")

I have the same issue on a similar data file, it only reads 57% of the file and stops "normally"

回答1:

If the data has mismatched quotes or octothorpes (or in some OSes cntrl-Z's) then abnormal termination of the file read may occur. You can sometimes get satisfactory results by resetting the defaults for quote and comment.char:

lem1 <- read.csv("lem1.csv", header=TRUE, sep =",", 
                             quote="", comment.char="")


标签: r file csv size