Skip to content

Instantly share code, notes, and snippets.

@ramnathv
Created November 26, 2012 18:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ramnathv/4149899 to your computer and use it in GitHub Desktop.
Save ramnathv/4149899 to your computer and use it in GitHub Desktop.
R Packages on Github
# Get repos with language = R and a given search term, for a given page
get_page <- function(search_term, page){
require(httr)
url = sprintf('https://api.github.com/legacy/repos/search/%s?language=R&start_page=%s',
search_term, page)
repos = GET(url)
return(content(repos)$repositories)
}
# check number of pages directly on github.com, since each page only returns 100 repos in the API call
RESULTS = 1613 # for package
PERPAGE = 100
pages = seq(1, ceiling(RESULTS/PERPAGE))
# assume package is defined by R repo with package in description
# other terms are NAMESPACE and INST
repos = Reduce('c', lapply(pages, get_page, search_term = 'package'))
# filter out forks to avoid double counting.
repos_orig = Filter(function(x) !(x$fork), repos)
# convert list of lists to a data frame of repos.
repos_data = do.call(rbind, repos_orig)
@ramnathv
Copy link
Author

NOTE. This list is not accurate as it misses out several packages on github. The key is to tweak search_term and come up with something that would account for all packages.

@ramnathv
Copy link
Author

Results of running this code available as a Google Spreadsheet at http://goo.gl/JVZHc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment