Apply the common-name precedence to the merged taxon table
Source: R/common_names.R
apply_taxon_common.RdSets common_name on tbl for every taxon as one COALESCE, in this order
(taxon plan D5):
Usage
apply_taxon_common(
con,
cache_csv,
tbl = "taxon",
dataset_taxon = "dataset_taxon",
curated = "swfsc_ichthyo",
group_rules = NULL,
verbose = TRUE
)Arguments
- con
DBI connection holding
tbl(anddataset_taxon, for ranks 2 and 4; without it those ranks are simply empty).- cache_csv
path to the registry (see
ensure_taxon_common()).- tbl
taxon table name (default
"taxon").- dataset_taxon
crosswalk table name (default
"dataset_taxon").- curated
the dataset whose vocabulary is rank 2 (default
"swfsc_ichthyo", the CalCOFI species list).- group_rules
the group registry as read by
read_taxon_group_rules(), or a path to it; itsdataset_taxonrules'match_values are labels rank 4 refuses.NULL(the default) refuses only the labels of dataset-local keys, which need no registry to recognise.- verbose
report how many names each rank supplied.
Value
a data.frame of per-rank counts (rank, source, n) — the five
ranks plus other_excluded_label, the taxa whose only rank-4 candidate was
a refused label — invisibly.
Details
a human choice in the registry (
source = "manual") — the override;the curated species list's own name —
dataset_taxon.ds_common_namewheredataset_key = curated(swfsc_ichthyo, CalCOFI's own names);WoRMS, when it offers exactly one English vernacular (
source = "worms",n_candidates_en = 1);any other dataset's
ds_common_name, indataset_keyorder (this is where the seabird and marine-mammal names come from — WoRMS holds almost no bird vernaculars) — except a label that is not a name: a value that is amatch_valueof adataset_taxonrule ingroup_rules(metadata/taxon_group.csv: "diatom, centric", "other", …) or theds_common_nameof any dataset-local (non-authority) key ("undefined (code not in source definitions; Q05)", zooscan "nauplii"). Those are what a source calls a group or an operational class, and rank 4 used to publish them as the common name of every taxon in the group (Ben, 2026-09-04: a group label is never acommon_name; the group's own name intaxon_groupis unchanged). The taxa that lose their only rank-4 candidate this way are counted asother_excluded_label;empty. Never a guess.
The merged table's existing common_name is not a rank: it is whichever
shard won the merge, which is the undocumented order this replaces.
When two codes of one dataset resolve to the same taxon (ichthyo 683
Sebastes "Rockfishes" and 3023 Sebastes crocotulus "Sunset rockfish" both
carry the genus AphiaID), the code whose ds_scientific_name equals
taxon.scientific_name — the code that is the taxon rather than one finer
or coarser than it — wins; failing that, ds_taxon_key ascending.
Called by release_database.qmd on the merged taxon table, so the registry
is applied once rather than in each of the 10 taxa-emitting ingests.