使用 R 下载 *.xls 文件产生错误

Using R to download *.xls files generates error

我正在尝试从 BLS 服务器下载大量 xls 文件。 当我手动下载任何文件时,它们都能完美打开。

但是当我尝试从 R 中下载文件时:

library(readxl)

tp <- "http://www.bea.gov/histdata/Releases/GDP_and_PI/2014/Q4/Third_March-27-2015/Section1ALL_Hist.xls"
temp <- paste0(tempfile(), ".xls")
download.file(tp, destfile = temp, mode = "wb")

这会下载一个大小合适的文件,但正在尝试读取该文件:

 data <- read_excel(path = temp, sheet = 1)

returns 错误

seek: wanted to seek to sector 5374034 (0x520052) loc=2751505920

设置mode="wb"进行二进制传输:

download.file(tp, destfile=temp, mode="wb")