使用 R 下载 Excel 文件

Gar*_*y H 4 excel r downloadfile

我正在尝试从哥伦比亚中央银行网站下载 Excel 文件,但通常的 download.file 功能似乎无法完成这项工作。

例如,我试图在此页面上下载第一个文件“Serie historya”:http : //www.banrep.gov.co/es/indice-tasa-cambio-real

文件链接如下,我在download.file函数中使用了 http://obieebr.banrep.gov.co/analytics/saw.dll?Download&Format=excel2007&Extension=.xls&BypassCache=true&path=%2Fshared%2FSeries% 20Estad%c3%adsticas_T%2F1.%20Indice%20de%20Tasa%20de%20Cambio%20Real%2F1.1.%20Serie%20historica_IQY&SyncOperation=1&NQUser=publico&NQPassword=publico

我使用的命令是:download.file(filepath, destfile, quiet=FALSE, mode="wb")

任何帮助是极大的赞赏!

Raf*_*íaz 5

我希望这个例子能指导你

library(readxl)
library(httr)
url1<-'https://evs.nci.nih.gov/ftp1/CDISC/SDTM/SDTM%20Terminology.xls'
GET(url1, write_disk(tf <- tempfile(fileext = ".xls")))
df <- read_excel(tf, 2L)
str(df)
Run Code Online (Sandbox Code Playgroud)

如果您可以下载该文件,您可以按如下方式阅读

library(readxl)
datos <- read_xlsx("C:/Users/USER/Downloads/1.1. Serie historica_IQY.xlsx", skip = 8, n_max = 369)
Run Code Online (Sandbox Code Playgroud)