
source_url
calls getURL
in
RCurl
package and then read the contents by
textConnection
, which is then
source
ed. See ?getURL
for the
available protocol.source_url(url, ..., sha1 = NULL)
source
sha1
argument,
then this function will check the SHA-1 hash of the
downloaded file to make sure it matches the expected value,
and throw an error if it does not match. If the SHA-1 hash
is not specified, it will print a message displaying the
hash of the downloaded file. The purpose of this is to
improve security when running remotely-hosted code; if you
have a hash of the file, you can be sure that it has not
changed. For convenience, it is possible to use a truncated
SHA1 hash, down to 6 characters, but keep in mind that a
truncated hash won't be as secure as the full hash.source_url("https://gist.github.com/hadley/6872663/raw/hi.r")
# With a hash, to make sure the remote file hasn't changed
source_url("https://gist.github.com/hadley/6872663/raw/hi.r",
sha1 = "54f1db27e60bb7e0486d785604909b49e8fef9f9")
# With a truncated hash
source_url("https://gist.github.com/hadley/6872663/raw/hi.r",
sha1 = "54f1db27e60")
Run the code above in your browser using DataLab