View source: R/completeMetadata.R
| completeMetadata | R Documentation |
Given a bibliometrix collection produced by convert2df, this
function takes the subset of records that have a usable lookup key (a DOI or
an OpenAlex Work ID) but are missing one or more of the analysis-relevant
fields, queries the Crossref REST API
(https://api.crossref.org/works) and/or OpenAlex (via
openalexR) and fills the gaps with the values returned by those
sources. Existing non-empty values are never overwritten.
completeMetadata(
M,
sources = c("openalex", "crossref"),
fields = c("AB", "AU", "C1", "CR", "DT", "LA", "PY", "RP", "SO", "TC", "TI"),
email = NULL,
oa_apikey = NULL,
batch_size = 20,
max_records = Inf,
progress = NULL,
verbose = TRUE
)
M |
Bibliometrix data frame produced by |
sources |
Character vector of enrichment sources.
Default |
fields |
Character vector of WoS-codified fields to attempt to fill.
Default |
email |
Optional contact email used as the Crossref polite-pool
identifier and OpenAlex |
oa_apikey |
Optional OpenAlex API key. If |
batch_size |
Number of DOIs per Crossref batch request (default 20). OpenAlex uses a fixed batch size of 50 (the maximum that keeps URLs under length limits). |
max_records |
Optional cap on the number of records to enrich
(useful for previewing). Default |
progress |
Optional callback |
verbose |
Logical. Print progress messages to the console. |
When both sources are enabled, OpenAlex runs first (broader coverage of
AB/CR/C1/TC) and Crossref then fills the residual gaps. OpenAlex records are
looked up by their Work ID (id_oa) when available - which is
essential for collections imported from a minimal OpenAlex CSV export that
omitted the DOI - and by DOI otherwise. Crossref is always keyed by DOI.
The vacancy predicate matches the one used by missingData:
a cell is considered missing when it is NA or one of
c("", "NA", "none", "NA,0000,NA").
Crossref cannot supply author keywords (DE), Keywords Plus (ID), Web of
Science categories (WC), or citation counts (TC). OpenAlex covers TC,
AB, AU, C1, CR, DT, LA, PY, RP, SO, TI well; OpenAlex keywords
are AI-derived topic labels and not author keywords, so DE is off by
default. ID and WC are always skipped.
A list with components:
MThe enriched collection (same class as the input).
reportLong-format data.frame with one row per
(field, source) summarising attempts, fills, and failures.
beforeThe mandatoryTags table from
missingData(M) before enrichment.
afterThe mandatoryTags table from
missingData(M) after enrichment.
Provenance is attached to the returned collection as
attr(M, "enrichment"), a long-format data.frame with columns
SR, field, source, timestamp.
## Not run:
data(scientometrics, package = "bibliometrixData")
res <- completeMetadata(scientometrics, email = "you@example.com")
res$report
res$after
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.