Skip to content

Instantly share code, notes, and snippets.

@MansMeg
Forked from christophergandrud/source_GitHubData.R
Created May 28, 2014 12:39
Show Gist options
  • Save MansMeg/f1160c4abe2264d0b8d3 to your computer and use it in GitHub Desktop.
Save MansMeg/f1160c4abe2264d0b8d3 to your computer and use it in GitHub Desktop.
#####################
# R function for downloading plain-text data from GitHub
# Christopher Gandrud
# 7 January 2013
#####################
# source_GitHubData is directly based on source_url from the Hadley Wickham's devtools package
source_GitHubData <-function(url, sep = ",", header = TRUE)
{
require(httr)
request <- GET(url)
stop_for_status(request)
handle <- textConnection(content(request, as = 'text'))
on.exit(close(handle))
read.table(handle, sep = sep, header = header)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment