Learn R Programming

repmis (version 0.2.4)

source_data: Load plain-text data from a URL (either http or https)

Description

source_data loads plain-text formatted data stored at a URL (both http and https) into R.

Usage

source_data(url, sep, header)

Arguments

url
The plain-text formatted data's URL.
sep
The separator method for the data. For example, to load comma-separated values data (CSV) use sep = ",". To load tab-separated values data (TSV) use sep = "t".
header
Logical, whether or not the first line of the file is the header (i.e. variable names).

Value

  • a data frame

source

Based on source_url from the Hadley Wickham's devtools package.

Details

Loads plain-text data (e.g. CSV, TSV) data from a URL. Works with both HTTP and HTTPS sites. Note: the URL you give for the 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.

See Also

httr and read.table

Examples

Run this code
# Download electoral disproportionality data stored on GitHub
# Note: Using shortened URL created by bitly
DisData <- source_data("http://bit.ly/Ss6zDO", sep = ",", header = TRUE)

Run the code above in your browser using DataLab