简体   繁体   English

R中的read.table问题

[英]problems with read.table in R

Here I have a .csv dataset containing 120211 observations for 19 variables. 在这里,我有一个.csv数据集,其中包含针对19个变量的120211个观察值。
Using read.table("test.csv",header=TRUE,sep=",") will yield the following error: 使用read.table("test.csv",header=TRUE,sep=",")将产生以下错误:

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. 然后,我在read.table参数中添加fill=TRUE ,不会显示任何错误。 However using this will only yield 41451 observations. 但是,使用此方法只会产生41451个观测值。 And the 41451st observation is actually the last one in my test.csv. 41451st观察实际上是我的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. 我想在41453行中的一个单元格(字符串/文本)中有一个附加的逗号。 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. 只需尝试使用文本编辑器(如notepad ++)检查41453行(因为您也必须计算标题行)即可确定问题所在。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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