scholar is an R package for pulling publication and citation data from Google Scholar profiles. It helps you answer the everyday questions that come up when maintaining a CV, checking a collaborator's profile, comparing citation trajectories, or doing a quick bibliometric sanity check.
Google Scholar has no official public API, so this package is necessarily a scraper. That means two things: use it gently, and expect occasional breakage when Google changes its HTML. I try to keep the package practical rather than magical; if a query can be done with a few small requests, scholar is a handy tool. If you want to crawl half of Google Scholar, life is short, don't do that.
Install the CRAN release:
install.packages("scholar")Or install the development version from GitHub:
if (!requireNamespace("remotes", quietly = TRUE)) {
install.packages("remotes")
}
remotes::install_github("YuLab-SMU/scholar")Most functions start from a Google Scholar profile ID. In this URL:
https://scholar.google.com/citations?user=B7vSqZsAAAAJ
the ID is B7vSqZsAAAAJ.
If you only have a name, try searching first:
library(scholar)
search_scholar_ids("Richard Feynman", max_pages = 1)
get_scholar_id(first_name = "Richard", last_name = "Feynman")If you copied a full URL, tidy_id() keeps only the useful part:
tidy_id("https://scholar.google.com/citations?user=B7vSqZsAAAAJ&hl=en")
#> "B7vSqZsAAAAJ"id <- "B7vSqZsAAAAJ"
profile <- get_profile(id)
profile$name
profile[c("total_cites", "h_index", "i10_index")]
pubs <- get_publications(id)
head(pubs)get_publications() returns a data frame with publication titles, displayed authors, venue text, citation counts, years, Google Scholar citation IDs, and publication IDs. This is usually the object you want to fetch once and reuse.
recent <- subset(pubs, !is.na(year) & year >= 2020)
get_publication_metrics(recent)Scholar profiles expose yearly citation bars. scholar turns them into a data frame, so plotting is just ordinary R code.
ct <- get_citation_history(id)
plot(
ct$year, ct$cites,
type = "b",
xlab = "Year",
ylab = "Citations"
)For article-level citation history, use a publication ID from get_publications():
get_article_cite_history(id, pubs$pubid[1])ids <- c("B7vSqZsAAAAJ", "DO5oG40AAAAJ")
compare_scholars(ids)
compare_scholar_careers(ids)compare_scholars() compares citation totals by publication year. compare_scholar_careers() aligns scholars by career year, which is often a fairer comparison than raw calendar year.
network <- get_coauthors("DO5oG40AAAAJ", n_coauthors = 5, n_deep = 0)
plot_coauthors(network)Keep n_coauthors and n_deep small. Coauthor graphs get messy quickly, and repeated requests may trigger rate limits. 强迫症想把网络挖到底?我懂,但 Google 不一定惯着你。
format_publications() returns publication strings that work nicely in R Markdown, Quarto, or CV workflows. The selected author can be highlighted in bold.
format_publications("DO5oG40AAAAJ", author.name = "Guangchuang Yu") |>
cat(sep = "\n\n")For a numbered list, print the returned vector directly:
format_publications("DO5oG40AAAAJ", author.name = "Guangchuang Yu") |>
print(quote = FALSE)A few useful helpers are easy to miss:
get_scholar_metrics()calculates h-index, g-index, i10-index, i50-index, i100-index, and related summaries.get_publication_data_extended()extracts extra metadata from a publication detail page.get_complete_authors()completes author lists that Google Scholar truncates with....author_position()checks where an author appears in publication author lists.get_journalrank()queries SCImago journal ranking data.predict_h_index()implements the Acuna et al. h-index prediction model; treat it as illustrative, not prophecy.
- Google Scholar may rate-limit repeated requests; small, focused queries are more reliable.
get_publications()caches results withR.cache; useflush = TRUEwhen you need fresh data.- Some Scholar profiles hide fields or have incomplete metadata, so
NAand empty values are normal. - For larger analyses, fetch publication data once, save it locally, and analyse the saved data frame.
pubs <- get_publications(id, flush = TRUE)
saveRDS(pubs, "scholar-publications.rds")The package vignette has a fuller walkthrough:
vignette("scholar", package = "scholar")Bugs and feature requests are welcome on GitHub: https://github.com/YuLab-SMU/scholar/issues.