Compare Herbarium Sources

Overview

When working with plant specimen data from multiple biodiversity repositories (e.g., GBIF, JABOT, speciesLink), users often encounter overlapping records across sources. barRoso offers the barroso_cat() function to merge, harmonize, and optionally deduplicate these datasets based on collection codes.

This article demonstrates how to:

  • Merge multiple data sources into a unified data frame
  • Combine raw speciesLink downloads with GBIF downloads
  • Prioritize a preferred source when herbaria overlap

Function: barroso_cat()

combined_df <- barroso_cat(
  list_sources = list(
    GBIF = gbif_data,
    speciesLink = splink_data,
    JABOT = jabot_data
  ),
  keep_source = "GBIF"
)

Arguments

  • list_sources: A named list of data frames, one per biodiversity source. The names (e.g. GBIF, speciesLink) must be unique, as they are used to identify the source of each record.
  • keep_source: Optionally, the name of the preferred source (e.g. "GBIF"). The records of any herbarium also present in the preferred source are removed from the other sources.

If no source is specified, the function merges all sources, retaining potential duplicates for further reconciliation with barroso_flag_duplicates().

Example

library(barRoso)

# Load datasets downloaded from GBIF and speciesLink
gbif <- read.csv("gbif.csv")
splink <- read.csv("speciesLink.csv", fileEncoding = "latin1")

# Merge, giving preference to GBIF for overlapping herbaria
combined_df <- barroso_cat(
  list_sources = list(
    GBIF = gbif,
    speciesLink = splink
  ),
  keep_source = "GBIF"
)

table(combined_df$datasource)

For example, when combining 9,806 GBIF records and 4,432 speciesLink records of Ormosia, 1,259 speciesLink records of 74 herbaria also available in GBIF are removed, resulting in 12,979 records (9,806 from GBIF and 3,173 from speciesLink).

How It Works

2. REFLORA and JABOT values are standardized

Records downloaded with refloraR and jabotR already have Darwin Core column names, but some of their values are written differently from GBIF. barroso_cat() recognizes these sources by their content, whatever their names in list_sources, and standardizes them:

Source Column Before After
REFLORA identifiedBy Administrador (the system user, in most records) NA
REFLORA eventDate, dateIdentified 2/12/1940, --/5/1880, 9/10/1990 até 12/10/1990 1940-12-02, 1880-05, 1990-10-09/1990-10-12
REFLORA typeStatus HOLOTYPUS, ISOTYPUS, TYPUS holotype, isotype, type
REFLORA institutionCode of RB RB JBRJ, as in GBIF and JABOT
JABOT eventDate, dateIdentified 2008-9-26, 22/4/2020, 4/2020 2008-09-26, 2020-04-22, 2020-04
library(refloraR)
library(jabotR)

reflora <- reflora_records(herbarium = c("RB", "K"), taxon = "Ormosia", save = FALSE)
jabot <- jabot_records(herbarium = c("MBM", "UPCB"), taxon = "Ormosia", save = FALSE)

combined_df <- barroso_cat(
  list_sources = list(GBIF = gbif, speciesLink = splink, REFLORA = reflora, JABOT = jabot),
  keep_source = "GBIF"
)

The REFLORA collection of RB is fed by JABOT, so the same RB specimens are often found in both sources, and also in GBIF. With keep_source = "GBIF", they are kept just once.

3. Overlapping herbaria are removed when keep_source is given

Overlapping herbaria are detected with collectionCode. When keep_source = "GBIF", the records of any herbarium present in GBIF are removed from the other sources. Herbaria shared only among the other sources (e.g. present in both speciesLink and JABOT, but not in GBIF) are kept in all of them, and their duplicates can then be flagged with barroso_flag_duplicates().

4. Columns are aligned

  • Columns missing in some sources are filled with NA.
  • Columns with different types across sources (e.g. year as numbers in GBIF and as text in speciesLink) are combined as text, instead of failing.
  • A new column datasource stores the source of each record (e.g. "GBIF", "speciesLink").

Tips

  • Name each data source in list_sources, e.g. list(GBIF = gbif, speciesLink = splink)
  • Ensure each dataset includes a collectionCode column, otherwise overlapping herbaria cannot be detected for that source
  • Use keep_source = NULL if you want to preserve all records
  • Use barroso_std() after combining to clean the remaining fields and flag duplicates
cleaned_df <- barroso_std(combined_df, flag_duplicates = TRUE)

See Also