Enrich corpus with OpenCitations citation data
Source:R/enrich-opencitations.R
sm_enrich_opencitations.RdLook up DOIs using the
OpenCitations Index API
and add outgoing references. DOI and OpenAlex identifiers link these
references to works in the corpus. The separate incoming citation count
replaces works$cited_by_count.
This enricher is idempotent: re-running it updates existing citation data rather than duplicating it.
Usage
sm_enrich_opencitations(corpus, verbose = TRUE, call = rlang::caller_env())Value
An sm_corpus object with updated cited_by_count in the
works table, outgoing references linked where possible, and new
provenance rows for works with usable responses.
Examples
# \donttest{
# Queries the OpenCitations web API.
if (requireNamespace("curl", quietly = TRUE) && curl::has_internet()) {
corpus <- sm_corpus(works = tibble::tibble(
work_id = "W1",
doi = "10.1016/j.joi.2017.08.007"
))
enriched <- try(sm_enrich_opencitations(corpus))
if (is_sm_corpus(enriched)) enriched$works[, c("doi", "cited_by_count")]
}
#> ℹ Looking up 1 DOIs on OpenCitations...
#> ✔ Enriched 1 works with OpenCitations data.
#> # A tibble: 1 × 2
#> doi cited_by_count
#> <chr> <int>
#> 1 10.1016/j.joi.2017.08.007 12084
# }