Not sure why it took me so long to get around to this, but I’ve finally created a little function that simplifies the process of downloading plain-text data from GitHub. It’s called source_GitHubData. (The name mimicks the devtools syntax for functions like source_gist and source_url. The function’s syntax is actually just a modified version of source_url.)

The function is stored in a GitHub Gist HERE (it’s also at the end of this post). You can load it directly into R with devtools’ source_gist command.

Here is an example of how to use the function to download the electoral disproportionality data I discussed in an earlier post.

# Load source_GitHubDatalibrary(devtools)

# The functions' gist ID is 4466237source_gist("4466237")

# Create Disproportionality data UrlAddress object# Make sure the URL is for the "raw" version of the file# The URL was shortened using bitlyUrlAddress <- "http://bit.ly/Ss6zDO"

# Download dataData <- source_GitHubData(url = UrlAddress)

# Show Data variable namesnames(Data)

## [1] "country" "year" "disproportionality"

There you go.

Note that the the function is set by default to load comma-separated data (CSV). This can easily be changed with the sep argument.