简体   繁体   English

带有制表符分隔文件的`read.table`错误

[英]`read.table` error with a tab separated file

I have a text document that is separated by tab. 我有一个由制表符分隔的文本文档。 I did notice a bunch of tabs after the data in the text doc and am unsure if that is the issue here. 我确实注意到文本文档中的数据之后有一堆标签,我不确定这是否是问题。

I have set the working directory: 我已经设置了工作目录:

setwd("D:/Classes/CSC/gmcar_price") setwd( “d:/类别/ CSC / gmcar_price”)

Then I attempt to read the table using 然后我尝试使用读表

data=read.table("gmcar_price.txt", header=T) data = read.table(“gmcar_price.txt”,header = T)

But this error is coming up: 但是这个错误即将出现:

Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : line 11 did not have 13 elements 扫描错误(文件,什么,nmax,sep,dec,quote,skip,nlines,na.strings,:第11行没有13个元素

Any idea what is going on here? 知道这里发生了什么吗? I have looked at line 11 and all the data is there. 我查看了第11行,所有数据都在那里。

Edit: 编辑:

this is the format of the data 这是数据的格式

Price,Mileage,Make,Model,Trim,Type,Cylinder,Liter,Doors,Cruise,Sound,Leather 价格,里程,品牌,型号,内饰,型号,汽缸,升门,巡航,音响,皮革

 data=read.table("gmcar.price.txt", header=T, sep = "\t")

感谢shujaa,这解决了我遇到的问题。

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

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