Created
February 20, 2023 13:45
-
-
Save damianooldoni/93ce226d9d4531095cd8428cd412f8c7 to your computer and use it in GitHub Desktop.
Basic R script to check changes in matching taxa to GBIF Backbone via `name_backbone()`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Example from prius project | |
# Load packages | |
library(rgbif) | |
library(tidyverse) | |
# Read checklist | |
checklist <- readr::read_csv("https://raw.githubusercontent.com/inbo/prius/main/data/input/prius_species_list.csv", | |
na = "", | |
locale = locale(encoding = "ISO-8859-1") | |
) | |
# get taxon info from GBIF Backbone | |
checklist_with_gbif_info <- | |
checklist %>% | |
pull(Species) %>% | |
map_dfr(name_backbone) | |
# Add prefix to all columns containing new GBIF derived information | |
colnames(checklist_with_gbif_info) <- paste('new_gbif', colnames(checklist_with_gbif_info), sep = '_') | |
# Add new GBIF information to the checklist | |
checklist_with_gbif_info <- | |
checklist %>% | |
bind_cols(checklist_with_gbif_info) | |
# Detect taxa where changes in usageKey occurred | |
changed_matches <- | |
checklist_with_gbif_info %>% | |
filter(new_gbif_usageKey != GBIF_code) | |
View(changed_matches) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment