在 r 中使用 read.xls 下载 CSV 文件

Downloading a CSV file using read.xls in r

我正在尝试从此 URL 导入 CSV 文件,但这行简单的代码在 URL.

上不起作用
read.csv("https://www.cboe.com/publish/vxthdata/vxth_dailydata.xls")

我尝试从 RCurl 库中获取URL,遇到同样的问题。

对了!只是忽略了它...

library(gdata)
read.xls("https://www.cboe.com/publish/vxthdata/vxth_dailydata.xls")

正如 MrFlick 所说,您的文件是 Excel 文件,而不是 CSV 文件。 您可以使用 readxlcurl.

url <- "https://www.cboe.com/publish/vxthdata/vxth_dailydata.xls"
destfile <- "vxth_dailydata.xls"
curl::curl_download(url, destfile)
vxth_dailydata <- readxl::read_excel(destfile, col_types = c("date", rep("numeric", 9)))
file.remove(destfile)
rm(url, destfile)
View(vxth_dailydata)

问候!!