7

I don't understand the warning message:

Warning message: In download.file(url, temp, quiet = TRUE, mode = "wb") : downloaded length 2533 != reported length 2533

If the numbers were different, I could understand. The code to reproduce:

url <- "http://www.waterqualitydata.us/Result/search?siteid=USGS-01594440&pCode=01075&countrycode=US&mimeType=tsv&zip=yes"
temp <- tempfile()
download.file(url,temp, quiet=TRUE, mode='wb')
doc <- unzip(temp)
unlink(temp)
retval <- read.delim(doc , header = TRUE, quote="\"", 
                  dec=".", sep='\t', 
                  fill = TRUE)

I can suppress the warning, but I want to make sure I'm not doing anything wrong either. Thanks!

edit: added the read.delim part to get a dataframe out. My platform is x86_64-w64-mingw32/x64 (64-bit), with R version 3.1.2 (2014-10-31).

x4nd3r
  • 855
  • 1
  • 7
  • 20
user3915170
  • 323
  • 2
  • 7
  • Yeah, sorry I should have added sessionInfo (it will be cramped in the comments I assume). I'm using Platform: x86_64-w64-mingw32/x64 (64-bit), with R version 3.1.2 (2014-10-31). – user3915170 Dec 15 '14 at 20:59
  • 2
    I had the exact same error message when I downloaded a package from CRAN yesterday also on a Windows 7 machine w/ R 3.1.2. Sounds like a bug in Pumpkin Helmet – Stedy Dec 15 '14 at 22:11
  • Can't reproduce on Linux with the same version of R. – nico Jan 07 '15 at 14:51
  • Strange, works fine for me on Win8.1Pro using Platform: x86_64-w64-mingw32 (64-bit console) and R 3.12. – mikeck Jan 12 '15 at 04:24
  • are you behind a proxy server? – hrbrmstr Feb 27 '15 at 20:34
  • All going smoothly here on Win7, R 3.1.2 (64). – Jason V Mar 17 '15 at 00:42
  • Works for me without error on same platform and version. – Thomas Mar 19 '15 at 13:19
  • Same thing has been happening to me on Windows using 3.1.2. The warning is annoying and I'd like to know why it appears too but it hasn't actually caused any issues. – Dason Apr 03 '15 at 14:10
  • As the URL does not have zip at the end the function does not know how to use the binary download. I'm guessing the the function tries to download the page not the file. Your URL should end with `.zip` not with the `Type=tsv&zip=yes` this **may** cause problems. I managed to run your code on Mac. – Konrad Apr 04 '15 at 20:25

1 Answers1

1

I am also on Platform: x86_64-w64-mingw32/x64 (64-bit) and do not have this problem under R 3.1.3. I get retval returned with 65 obs of 62 variables.

user3915170, just to reiterate what others have said above.

  1. First try upgrade R version from Pumpkin Helmet as @Stedy suggests.

    And let us know if it is still a problem.

  2. Check your quote marks on sep. I noticed you have them as single not double. (It worked for me as you had them, but might be an issue on R3.1.2)

    retval <- read.delim(doc, header = TRUE, quote="\"", 
                     dec = ".", sep = "\t", 
                     fill = TRUE)
    

    read.delim is just a special case of read.table with set defaults - from help "default(s) to the TAB character for the delimiter." So this sep setting is unnecessary and may be the fly in the ointment. So try it also without the sep operator, and see if you get the warning.

  3. Something similar has cropped up before on Stack Overflow but with a wider mismatch - only getting 200 bytes back.

    You are using mode='wb' which fixed https://stackoverflow.com/a/13803331/4606130. Not understanding type is something Konrad suggested whose comment is lost lower down in the comment list.

    But issue 16761056 had others there suggesting checking network connections, or a problem in download.file function. Have you tried running code from another location? All long shots but at least you are not alone with these warning messages!

Good luck and hope the upgrade solves this!

M

Community
  • 1
  • 1
micstr
  • 5,080
  • 8
  • 48
  • 76