I am a little rusty as I don't use R as much as before.
I have R code that I wrote years ago that suddenly stopped working when the source URL changed from a 'http:" to "https:"
destfile = "C:/Temp/tmpcftc.zip"
url = "http://www.cftc.gov/files/dea/history/com_disagg_txt_2015.zip"
download.file(url, destfile)
df = read.csv(unz(destfile, "c_year.txt"))
When the code stopped working I noticed that the URL changed to "https:" so I made the following change:
destfile = "C:/Temp/tmpcftc.zip"
url = "https://www.cftc.gov/files/dea/history/com_disagg_txt_2015.zip"
download.file(url, destfile)
df = read.csv(unz(destfile, "c_year.txt"))
But, now I get the following error:
trying URL 'https://www.cftc.gov/files/dea/history/com_disagg_txt_2015.zip'
Error in download.file(url, destfile) :
cannot open URL 'https://www.cftc.gov/files/dea/history/com_disagg_txt_2015.zip'
In addition: Warning message:
In download.file(url, destfile) :
InternetOpenUrl failed: 'An error occurred in the secure channel support'
I can download the URL without issue from the internet browser but not with the code above.
Any assistance in pointing me in the right direction would be greatly appreciated.
I could reproduce the error. Solution for me was to add the line
to the .Renviron file. Restart R and the download should work with the code from the question.