2

I'm trying to get citation counts for different R packages. I know that scholar uses Google Scholar to get a list of publications given user's id.

Suppose that the only information we have is from citation("package"), is there a way to get citation count of this package from Google Scholar? Maybe there is meta-data that contains this information or a package that does that?

There is a similar question -- Retrieve citations of a journal paper using R

But from what I've seen, citation("package") looks different for every package, so there is no way of automatically retrieving publication title.

damir
  • 336
  • 2
  • 9

1 Answers1

1

If the R package contains a bibtex-format citation you can pull the title then gather citations for each one as shown in the link you posted. This example pulls all packages on CRAN and checks for citation info:

library(httr)
library(RCurl)
library(XML)

urldata <- getURL("https://cran.r-project.org/web/packages/available_packages_by_date.html")
CRAN <- readHTMLTable(urldata,
                      stringsAsFactors = FALSE)
CRAN_packages <- CRAN[["NULL"]][[" Package "]]
packages_df <- as.data.frame(CRAN_packages,
                             stringsAsFactors = FALSE)
list_of_citations <- NULL

for (f in 1:nrow(packages_df)) {
  tryCatch({
    list_of_citations <<- append(list_of_citations,
                                 citation(package = packages_df$CRAN_packages[f],
                                          auto = TRUE))
    }, error=function(e){
      cat(paste("No citations available for package",
                packages_df$CRAN_packages[f],
                sep = " "),
          conditionMessage(e), "\n")
      })
}

list_of_citations$title

Interestingly, out of the 15,556 packages on CRAN very few have properly formatted citation information available... Other people have pointed out this problem (e.g. https://stat.ethz.ch/pipermail/r-devel/2010-November/058977.html) but the issue has not yet been resolved (or maybe my code isn't capturing them all)

jared_mamrot
  • 22,354
  • 4
  • 21
  • 46