Burry  Xie
Burry Xie

Reputation: 95

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.

Upvotes: 0

Views: 1165

Answers (1)

floe
floe

Reputation: 417

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.

Upvotes: 1

Related Questions