Created
November 26, 2012 18:52
-
-
Save ramnathv/4149899 to your computer and use it in GitHub Desktop.
R Packages on Github
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.