Skip to contents

This function performs three checks:

  • keys are valid GBIF taxon keys. That means that adding a key at the end of the URL https://www.gbif.org/species/ returns a GBIF page related to a taxa.

  • keys are taxon keys of the GBIF Backbone Taxonomy checklist. That means that adding a key at the end of the URL https://www.gbif.org/species/ returns a GBIF page related to a taxa of the GBIF Backbone.)

  • keys are synonyms of other taxa (taxonomicStauts neither ACCEPTED nor DOUBTFUL).

.

Usage

gbif_verify_keys(keys, col_keys = "key")

Arguments

keys

(character or numeric) a vector, a list, or a data.frame containing the keys to verify.

col_keys

(character) name of column containing keys in case keys is a data.frame.

Value

a data.frame with the following columns:

  • key:(numeric) keys as input keys.

  • is_taxonKey : (logical) is the key a valid GBIF taxon key?

  • is_from_gbif_backbone :(logical) is the key a valid taxon key from GBIF Backbone Taxonomy checklist?

  • is_synonym : (logical) is the key related to a synonym (not ACCEPTED or DOUBTFUL)?

If a key didn't pass the first check (is_taxonKey = FALSE) then NA for other two columns. If a key didn't pass the second check (is_from_gbif_backbone = FALSE) then is_synonym = NA.

Examples

# input is a vector
keys1 <- c(
  "12323785387253", # invalid GBIF taxonKey
  "128545334", # valid taxonKey, not a GBIF Backbone key
  "1000693", # a GBIF Backbone key, synonym
  "1000310", # a GBIF Backbone key, accepted
  NA, NA
)
# input is a df
keys2 <- data.frame(
  keys = keys1,
  other_col = sample.int(40, size = length(keys1)),
  stringsAsFactors = FALSE
)
# input is a named list
keys3 <- keys1
library(purrr)
names(keys3) <- purrr::map_chr(
  c(1:length(keys3)),
  ~ paste(sample(c(0:9, letters, LETTERS), 3),
    collapse = ""
  )
)
# input keys are numeric
keys4 <- as.numeric(keys1)

gbif_verify_keys(keys1)
#> [1] "Key 12323785387253 is an invalid GBIF taxon key."
#> [1] "Key 128545334 is an invalid GBIF taxon key."
#> # A tibble: 4 × 4
#>       key is_taxonKey is_from_gbif_backbone is_synonym
#>     <dbl> <lgl>       <lgl>                 <lgl>     
#> 1 1.23e13 FALSE       NA                    NA        
#> 2 1.29e 8 FALSE       NA                    NA        
#> 3 1.00e 6 TRUE        TRUE                  TRUE      
#> 4 1.00e 6 TRUE        TRUE                  FALSE     
gbif_verify_keys(keys2, col_keys = "keys")
#> [1] "Key 12323785387253 is an invalid GBIF taxon key."
#> [1] "Key 128545334 is an invalid GBIF taxon key."
#> # A tibble: 4 × 4
#>       key is_taxonKey is_from_gbif_backbone is_synonym
#>     <dbl> <lgl>       <lgl>                 <lgl>     
#> 1 1.23e13 FALSE       NA                    NA        
#> 2 1.29e 8 FALSE       NA                    NA        
#> 3 1.00e 6 TRUE        TRUE                  TRUE      
#> 4 1.00e 6 TRUE        TRUE                  FALSE     
gbif_verify_keys(keys3)
#> [1] "Key 12323785387253 is an invalid GBIF taxon key."
#> [1] "Key 128545334 is an invalid GBIF taxon key."
#> # A tibble: 4 × 4
#>       key is_taxonKey is_from_gbif_backbone is_synonym
#>     <dbl> <lgl>       <lgl>                 <lgl>     
#> 1 1.23e13 FALSE       NA                    NA        
#> 2 1.29e 8 FALSE       NA                    NA        
#> 3 1.00e 6 TRUE        TRUE                  TRUE      
#> 4 1.00e 6 TRUE        TRUE                  FALSE     
gbif_verify_keys(keys4)
#> [1] "Key 12323785387253 is an invalid GBIF taxon key."
#> [1] "Key 128545334 is an invalid GBIF taxon key."
#> # A tibble: 4 × 4
#>       key is_taxonKey is_from_gbif_backbone is_synonym
#>     <dbl> <lgl>       <lgl>                 <lgl>     
#> 1 1.23e13 FALSE       NA                    NA        
#> 2 1.29e 8 FALSE       NA                    NA        
#> 3 1.00e 6 TRUE        TRUE                  TRUE      
#> 4 1.00e 6 TRUE        TRUE                  FALSE