R/getCitationCounts.R

Defines functions getCitationCounts

Documented in getCitationCounts

#' Counts the number of citations for each target ID.
#'
#' `getCitationCounts` counts the number of citations for each target ID in an edge list

#' @details
#' The edge list `e` must have a `Target` column. The number of citations for each
#' `Target` are counted. All citations per `Target` are assumed to be unique.
#' 
#' @param e an edge list, as obtained from `generateEdgeList` 
#' @return A tibble with one column for target PMIDS and one column, 'n', containing the corresponding citation frequencies
#' @seealso \code{\link{generateEdgeList}} for generating an edge list
#' 
#' @examples
#' 
#' # generates an edge list for multiple articles
#' res <- get_pmc_cited_in(c(21876761, 311,29463753))
#' e <- generateEdgeList(res)
#' counts <- getCitationCounts(e)

#' @export
getCitationCounts <- function(e) {

  if (!requireNamespace("dplyr", quietly = TRUE)) {
    stop("Package \"dplyr\" needed for this function to work. Please install it.",
      call. = FALSE)
  }


dplyr::count(  dplyr::group_by(e, Target)  )
}
gdancik/pmc2nc documentation built on May 5, 2019, 7:09 a.m.