I am relatively new to R programming. I am trying to download a few zip files which contain CSV files using URL and read them. Below are the code, URL and the errors. From errors I suspect it is only downloading some text or html code and not the ZIP file (the download is only 10KB as against 396KB for the ZIP file as shown on website). I have tried downloading a few other datsets from same site, but having the same issue. Appreciate if someone can help. Please note, I can directly download the ZIP files, extract and view the CSV files.
tempdl <- tempfile()
download.file("https://www.kaggle.com/russellyates88/suicide-rates-overview-1985-to-2016/downloads/suicide-rates-overview-1985-to-2016.zip",tempdl, mode="wb")
unzip(tempdl, "master.csv")
data <- read.table("master.csv", sep=",")
the error I get is:
> download.file("https://www.kaggle.com/russellyates88/suicide-rates-overview-1985-to-2016/downloads/suicide-rates-overview-1985-to-2016.zip",tempdl, mode="wb")
trying URL 'https://www.kaggle.com/russellyates88/suicide-rates-overview-1985-to-2016/downloads/suicide-rates-overview-1985-to-2016.zip'
Content type 'text/html; charset=utf-8' length unknown
downloaded 10 KB
> unzip(tempdl, "master.csv")
Warning message:
In unzip(tempdl, "master.csv") : error 1 in extracting from zip file
> data <- read.table("master.csv", sep=",")
Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") :
cannot open file 'master.csv': No such file or directory