Skip to contents

Look 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())

Arguments

corpus

An sm_corpus object.

verbose

Print progress messages?

call

Caller environment for error reporting.

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
# }