简体   繁体   中英

problems with read.table in R

Here I have a .csv dataset containing 120211 observations for 19 variables.
Using read.table("test.csv",header=TRUE,sep=",") will yield the following error:

scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : line 19 has no 19 variables

Then I add the fill=TRUE in read.table arguments and no error will be shown. However using this will only yield 41451 observations. And the 41451st observation is actually the last one in my test.csv.

Can anyone help me ? Thanks.

Without the dataset it is hard to check what the problem is. I suppose in line 41453 there is in one cell (string/text) an additional comma. Are the text/string variables quoted? Just try to check the line 41453 (because you have to count the header line, too) with a text editor like notepad++ to identify your problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM