Error in file.download when downloading custom file
download, r
Solution
OK, I figured out what was wrong. Because this url does not specifically have ".zip" at the end, the download.file function does not know to use a binary download. This code fixes the problem:
url1 <- http://www.clinicaltrials.gov/ct2/results?cond=%22acne%22&studyxml=true
tempZip <- tempfile()
download.file(url1, tempZip, mode="wb")
If you don't specify the mode argument, the downloaded zip file will be corrupt.
Problem
I'm trying to download the zip file from this url: ``` url1 <- http://www.clinicaltrials.gov/ct2/results?cond=%22acne%22&studyxml=true ``` Here's my code: ``` tempZip <- tempfile() download.file(url1, tempZip) ``` And here's the error I get: ``` Warning message: In download.file(url1, tempZip) : downloaded length 817445 != reported length 200 ``` Any ideas? EDIT: OK, after seeing agstudy's reply below, I found that the file was indeed being downloaded (it also appears to be the correct file size). Now the problem is when I try to unzip the file - it days the file is corrupted. Maciej, I agree that it would be better to use a link with a .zip extension, however, there's no way to get that from this website.