download.file
Download a File from the Internet
Description
Downloads a file from the Internet and saves the result to the specified file.
Usage
download.file(url, destfile, method, quiet = FALSE, mode = "w",
cacheOK = TRUE, extra = getOption("download.file.extra"))
Arguments
url |
a character string containing the URL of the resource to download.
The URL should include the transport protocol (for example, "http://", "ftp://" or "file://".
|
destfile |
a character string specifying the name of where the downloaded file
is saved.
|
method |
This argument is ignored.
|
quiet |
a logical value. If TRUE, status messages are not printed, and the progress
bar is not displayed. The default is FALSE.
|
mode |
a character string denoting the mode for opening and writing the file.
This argument is valid for only the "internal" method. Possible values are as follows:
"r" or "rt" | | reading in text mode. |
"w" or "wt" | | writing in text mode. |
"a" or "at" | | appending in text mode. |
"rb" | | reading in binary mode. |
"wb" | | writing in binary mode. |
"r+" or "a+b" | | reading and writing. |
"w+" or "w+b" | | reading and writing, but the file will be truncated initially. |
"a+" or "a+b" | | reading and appending.
|
If a specified value for this argument is missing, the default value is "w" or "wb" (for those compressed files with
an extension of .gz, .bz2, .gz or .zip).
|
cacheOK |
This argument is ignored.
|
extra |
This argument is ignored.
|
Value
returns an invisible status code. 0 indicates a successful download.
Other error codes are returned by different methods.
Side Effects
The file destfile is created.
Proxy Configuration
Configure the proxy servers by setting environment variables in the
environment before starting Spotfire Enterprise Runtime for R.
The following environment variables are recognized:
protocol_proxy
Set the proxy for all
protocol requests. This environment variable should be in one of these formats:
| | |
protocol://user:password@host:port
protocol://user:password@host
protocol://host:port
protocol://host
user:password@host:port
user:password@host
host:port
host
|
all_proxy
Sets the proxy for all requests not covered by individual protocol_proxy
environment variables.
no_proxy
Specifies a comma-separated list of hostnames that should not be accessed through the proxy. Proxy
support is disabled if this environment variable is set to "*".
All upper-case versions of the above environment variables (with the exception of
http_proxy) are recognized with the same semantics.
See Also
Examples
# Get a copy of Spotfire's home page, store in a tempfile, look at a bit of it
tf <- tempfile(fileext = ".html")
download.file("http://tibco.spotfire.com", tf)
substring(readLines(tf, n=7), 1, 50)
# Remove tempfile when finished:
unlink(tf)
# Get weather data from Smith Island, at east end of Strait of
# Juan de Fuca (Washington, USA). Read the data into a data.frame.
# (This URL is subject to change and so is the
# format of the file.)
## Not run:
wtmpfile <- tempfile("weather")
download.file("http://www.ndbc.noaa.gov/data/realtime2/SISW1.txt",
wtmpfile)
weatherDF <- read.table(wtmpfile, header=FALSE)
# Remove tempfile when finished:
unlink(wtmpfile)
## End(Not run)