source_data
loads plain-text or RDATA formatted data stored at a URL
(both http and https) into R.
source_data(url, rdata, sha1 = NULL, cache = FALSE, clearCache = FALSE, sep = "auto", header = "auto", stringsAsFactors = FALSE, envir = parent.frame(), ...)
url
must end in a distinguishing file extension..RDATA
file.
If not specified than source_url
will attempt to determine whether or
not the file is an .RDATA
file from the URL's extension.source_data
. Note if you are using data stored using Git, this is not
the file's commit SHA-1 hash.sep = ","
. To load
tab-separated values data (TSV) use sep = "\t"
. Only relevant for
plain-text data.url
argument
must be for the RAW version of the file. The function should work to download
plain-text data from any secure URL (https), though I have not verified this.From the source_url
documentation: "If a SHA-1 hash is specified with
the 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."
fread
, and load
## Not run:
# # Download electoral disproportionality data stored on GitHub
# # Note: Using shortened URL created by bitly
# DisData <- source_data("http://bit.ly/156oQ7a")
#
# # Check to see if SHA-1 hash matches downloaded file
# DisDataHash <- source_data("http://bit.ly/Ss6zDO",
# sha1 = "dc8110d6dff32f682bd2f2fdbacb89e37b94f95d")
# ## End(Not run)
Run the code above in your browser using DataLab