knitr必须下载zip文件时出错

knitr必须下载zip文件时出错,r,curl,zip,knitr,rstudio,R,Curl,Zip,Knitr,Rstudio,由于与网络安全系统冲突,我可以将数据文件从internet下载到网络中可以在R中使用的区域的唯一方法是通过R本身进行下载。当我在RStudio中运行脚本时,它工作得很好。当我尝试编写脚本时,我将收到消息不支持的URL,或者收到 Error in file(file, "rt") : cannot open the connection Calls: <Anonymous> ... withVisible -> eval -> eval -> read.csv -&

由于与网络安全系统冲突,我可以将数据文件从internet下载到网络中可以在R中使用的区域的唯一方法是通过R本身进行下载。当我在RStudio中运行脚本时,它工作得很好。当我尝试编写脚本时,我将收到消息
不支持的URL
,或者收到

Error in file(file, "rt") : cannot open the connection 
Calls: <Anonymous> ... withVisible -> eval -> eval -> read.csv -> 
    read.table -> file
Execution halted
文件(文件“rt”)中出错:无法打开连接
电话:

我正在使用Windows7和RStudio


重复:这只是编织文档时的问题,而不是运行脚本时的问题。

问题在于https和文件是二进制文件。通过将URL更改为http并将file.download设置为mode=“wb”,问题得到解决,脚本可以成功编写

最后的代码块如下所示

url <- "http://d396qusza40orc.cloudfront.net/repdata%2Fdata%2Factivity.zip"
download.file(url, "repdata-data-activity.zip", mode="wb")
unzip("repdata-data-activity.zip")
url
url <- "http://d396qusza40orc.cloudfront.net/repdata%2Fdata%2Factivity.zip"
download.file(url, "repdata-data-activity.zip", mode="wb")
unzip("repdata-data-activity.zip")