我将csv文件从Quandl
数据库加载到R中。
该文件以逗号分隔,数据如下所示:
quandl code,name
WIKI/ACT,"Actavis, Inc."
WIKI/ADM,"Archer-Daniels-Midland Company"
WIKI/AEE,"Ameren Corporation"
...
...
我使用以下代码加载数据:
US.Stocks <-read.table(file=ABC,header=FALSE,sep=",")
然而,我收到以下错误:
Error in read.table(data.frame(file = ABC, header = FALSE, :
'file' must be a character string or connection
有人可以帮我解决我做错的事吗?怀疑我没有在read.csv命令中对某些参数进行分类?
感谢 汤姆
答案 0 :(得分:0)
你应该使用
read.csv(file = yourFilePath, header = TRUE)
但我认为问题出在您的文件路径中,可能您缺少文件扩展名并记得将文件路径包装成双qoutes(“yourfilepath”)
<强>更新强>
read.csv
只是read.table
的包装器,带有一些默认参数
function (file, header = TRUE, sep = ",", quote = "\"", dec = ".",
fill = TRUE, comment.char = "", ...) {
read.table(file = file, header = header, sep = sep, quote = quote,
dec = dec, fill = fill, comment.char = comment.char, ...)
}