[Rd] Suggestion: Change default to download.file(..., mode="wb") ...instead of mode="w" with some bells and whistles
Henrik Bengtsson
hb at biostat.ucsf.edu
Wed Aug 29 21:27:53 CEST 2012
Hi,
I keep seeing the problem where people are download binary files as
text (mode="w") when using R's download.file() for FTP/HTTP downloads.
It often results in unnecessary troubleshooting until one concludes
that the downloaded file has been corrupted due to (what I think is)
translated newlines. Search the r-help mailing list and you'll find
other examples of this. This may or may not only be a problem for
Windows users.
I'd like to suggest to change the default of argument 'mode' of
download.file() to be mode="wb". The "default" is current mode="w"
except when argument 'mode' is missing (not explicitly given),
download.file() tries to be helpful by forcing 'mode' to be "wb" for
certain filename extensions. NB: help("download.file",
package="utils") has a paragraph on all this. BTW, the latter seems
to be done in a case-sensitive way, such that *.zip and *.ZIP will
have different behaviors.
Wouldn't it just be safer to change the default to mode="wb"? ...or
are there use cases that I'm overseeing - is anyone out there
intentionally using the "text" transfer mode?
/Henrik
More information about the R-devel
mailing list