Skip to content

Commit

Permalink
don't make requests to SO by default + update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
hfrick committed May 26, 2017
1 parent eabfaf8 commit 7b5d3fb
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 4 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export(combine_metrics)
export(cran_metrics)
export(getGitHub)
export(get_pkgs)
export(package_list_metrics)
export(scrape_github_package_page)
export(so_metrics)
importFrom(dplyr,"%>%")
9 changes: 6 additions & 3 deletions R/combine_metrics.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,22 @@
#' Combines metrics on a package from CRAN and Github
#'
#' @param package_name name of CRAN package - case-sensitive.
#' @param includeSO Logical. Include metrics from StackOverflow?
#'
#' @return a tibble of package information.
#' @export
#' @examples
#'
#' combine_metrics("dplyr")
#'
combine_metrics <- function(package_name) {
combine_metrics <- function(package_name, includeSO = FALSE) {
c_pkg <- cran_metrics(package_name)
git_pkg <- scrape_github_package_page(package_name)
so_pkg <- so_metrics(package_name)
res <- dplyr::full_join(c_pkg, git_pkg, by = "package")
res <- dplyr::full_join(res, so_pkg, by = "package")
if (includeSO){
so_pkg <- so_metrics(package_name)
res <- dplyr::full_join(res, so_pkg, by = "package")
}
return(res)
}

Expand Down
4 changes: 4 additions & 0 deletions R/stackOverflow.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
#' @return A vector of packages mentioned in StackOverflow questions on the \code{topic}.
#' @export
#' @examples
#' \dontrun{
#' get_pkgs(topics = "table", tag = "r", pagesize = 100, num_pages = 2)
#' get_pkgs(topics = c("table", "memory"), tag = "r", pagesize = 100, num_pages = 2)
#' }
get_pkgs <- function(topics, tag = "r", pagesize = 100, num_pages = 200, repos =
"https://cran.rstudio.com", ...){

Expand Down Expand Up @@ -76,7 +78,9 @@ get_hits <- function(pkg, tag = "r", pagesize = 100, num_pages = 200, ...){
#' @return A data.frame of package information.
#' @export
#' @examples
#' \dontrun{
#' so_metrics("dplyr")
#' }
so_metrics <- function(package_name){
tibble::tibble(package = package_name,
sohits = get_hits(pkg = package_name))
Expand Down
4 changes: 3 additions & 1 deletion man/combine_metrics.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions man/get_pkgs.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions man/package_list_metrics.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions man/so_metrics.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7b5d3fb

Please sign in to comment.