当我使用 read.table 获取数据时,出现了一件奇怪的事情。
data=read.table('/home/tiger/nasdaqlisted.txt',head=T,sep='|')
dim(data)
[1] 750 6
Run Code Online (Sandbox Code Playgroud)
事实上,文件中有2454行,有什么问题吗?
http://freeuploadfiles.com/bb3cwypih2d2
我认为问题在于某些名称包含引号字符'(在诸如 之类的名称中Angie's List, Inc.)。需要更改默认参数read.table才能正确读取数据。quote"\"'"
read.table("path/to/file", header=TRUE, sep="|", quote="")
Run Code Online (Sandbox Code Playgroud)
根据 @mrdwab 建议,read.delim使用"\""默认quote参数即可工作,无需任何更改:
read.delim("path/to/file", header=TRUE, sep="|")
Run Code Online (Sandbox Code Playgroud)