【发布时间】:2019-03-31 06:53:49
【问题描述】:
我正在尝试使用带有以下代码的 R 下载列表:
name <- paste0("https://www.sec.gov/Archives/edgar/full-index/2016/QTR1/master.idx")
master <- readLines(url(name))
master <- master[grep("SC 13(D|G)", master)]
master <- gsub("#", "", master)
master_table <- fread(textConnection(master), sep = "|")
最后一行返回错误。我验证了textConnection 按预期工作,我可以使用readLines 从中读取,但fread 返回错误。 read.table 遇到了同样的问题。
Error in fread(textConnection(master), sep = "|") : input= must be a single character string containing a file name, a system command containing at least one space, a URL starting 'http[s]://', 'ftp[s]://' or 'file://', or, the input data itself containing at least one \n or \r
我做错了什么?
【问题讨论】:
-
我的解决方法是使用
read.delim,然后使用setDT,但我仍然不明白出了什么问题。
标签: r data.table fread read.table