read.xlsx loadWorkbook(file, password = password) 错误:找不到

read.xlsx Error in loadWorkbook(file, password = password) : Cannot find

我正在尝试使用 'xlsx' 包从 link“https://www.ons.gov.uk/file?uri=/economy/grossvalueaddedgva/datasets/regionalgvaibylocalauthorityintheuk/1997to2015/regionalgvaibylainuk.xls”打开 .xls 文件,但似乎无法正常工作。我也尝试过 'gdata' 等其他软件包,但均未成功。

install.packages('xlsx')
require('xlsx')

file <- system.file('https://www.ons.gov.uk/file?uri=/economy/grossvalueaddedgva/datasets/regionalgvaibylocalauthorityintheuk/1997to2015/regionalgvaibylainuk.xls', package = "xlsx")
res <- read.xlsx(file, 5) # read the fifth sheet

我收到这个错误: 'Error in loadWorkbook(file, password = password) : Cannot find'

我也试过 read.xls() 函数,但它也抛出一个错误。

我觉得的回答可以用在这里:

library(httr)
library(xlsx)

url1<-'https://www.ons.gov.uk/file?uri=/economy/grossvalueaddedgva/datasets/regionalgvaibylocalauthorityintheuk/1997to2015/regionalgvaibylainuk.xls'
GET(url1, write_disk(tf <- tempfile(fileext = ".xls")))
res <- read.xlsx(tf, 5)