Learn R Programming

pacha (version 0.1.1)

compare_pacha: Compare the web API and local ColDP source

Description

Validates and compares the data returned by both sources for one species. The comparison always queries the API and the local ColDP archive, regardless of the configured default source. It normalizes case, accents, punctuation, and whitespace before assessing agreement, while retaining the original source values in the printed result and returned report. Sustainable uses are compared as category :: value pairs, so a value moved between categories is reported as a discrepancy rather than overlooked.

Usage

compare_pacha(
  species,
  component = "all",
  language = NULL,
  refresh = FALSE,
  print = TRUE
)

Value

Invisibly, a list with species, language, components, summary, details, api_record, coldp_record, and compared_at. summary is a data frame with one row per selected component and its agreement status.

Arguments

species

Character scalar containing at least a genus and specific epithet.

component

One or more components to compare. Use "all" (the default) for the full comparison, or select "common_names", "sustainable_uses", "indexation_urls", "establishment", and/or "threat_status" individually. Recognized aliases map to these standard components as follows: "names" to "common_names"; "uses" to "sustainable_uses"; "urls" to "indexation_urls"; "origin" to "establishment"; and "threat" and "conservation" to "threat_status". Matching is case-insensitive and tolerant of spaces or hyphens in place of underscores.

language

Optional output-language code or alias retained in the report metadata; the comparison itself is language-neutral.

refresh

Logical scalar. If TRUE, forces both source records to be refreshed before comparison.

print

Logical scalar. If TRUE, prints the comparison result.

Details

The function prints a concise, component-by-component result by default and returns the full machine-readable report invisibly. Status values are "identical", "partial_overlap", "discrepant", "one_source_missing", "both_missing", "api_unavailable", and "coldp_unavailable". With component = "all", it compares common names, sustainable uses, indexation URLs, establishment status, and threat status.

Examples

Run this code
if (FALSE) {
compare_pacha("Bidens andicola")
compare_pacha("Bidens andicola", component = "sustainable_uses")
compare_pacha("Bidens andicola", component = c("origin", "threat"))
compare_pacha("Bidens andicola", component = c("names", "urls"), print = FALSE)
}

Run the code above in your browser using DataLab