Combine two corpora, assigning new IDs to colliding records in the
second input and rewriting their links in every table and embedding.
This includes yearly citation counts (citations_by_year). The bound
corpus keeps the metadata of corpus1, with the local input files
(sm_register_input()) of both corpora, each file and content once.
Arguments
- corpus1
An
sm_corpus.- corpus2
An
sm_corpus.- mix_models
Logical; bind embeddings that come from different models (or of which only one corpus records its model)? Defaults to
FALSE. See Details.- verbose
Logical; report the number of re-keyed IDs and works whose normalised DOI also occurs in the first input?
Details
Work IDs shared by the inputs always get new values in corpus2.
Author, source and institution IDs are shared only when their lookup
rows agree on every common column, including missing and list values.
Other collisions get new IDs above the numbers used by either input;
external cited work IDs are reserved too. Shared DOIs remain separate
records until sm_dedupe() is called. The merged corpus is unlocked.
Embeddings are bound when both corpora have them, with the same number
of dimensions, and when they come from the same model as
metadata$embedding records it (see sm_corpus()); the bound corpus
keeps that record. Embeddings that record different models, or of
which only one corpus records its model, are not comparable: the
function stops (class scimapR_embedding_model_mismatch) unless
mix_models = TRUE, which binds them and records the model as
"mixed". Embeddings of two corpora that record no model, such as
corpora embedded by earlier versions of scimapR, are bound as before,
and the model of the bound rows stays unrecorded. When only one corpus
has embeddings, or their widths differ, the bound corpus has none and
warns with class scimapR_bind_embeddings_dropped.
Examples
c1 <- sm_example_corpus(n_works = 20, seed = 1)
c2 <- sm_example_corpus(n_works = 20, seed = 2)
bound <- sm_bind_corpora(c1, c2)
#> ℹ Re-keyed 20 works, 80 authors, 10 sources and 0 institutions in the second
#> corpus.
#> ℹ 20 works share a DOI with the first corpus; use `sm_dedupe()` to remove
#> duplicates.
nrow(bound$works)
#> [1] 40