Last active
October 8, 2018 09:41
-
-
Save damianooldoni/c305a4383fc4ea0518871d5fa7fc550e to your computer and use it in GitHub Desktop.
name_usage() returns issues as codes. This code shows how replace the codes with the corresponding issues
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
devtools::install_github("ropensci/rgbif") | |
library(rgbif) | |
library(tidyverse) | |
library(rgbif) | |
# GBIF taxon keys (from Manual of Alien Plants of Belgium) | |
keys <- c(141264614, 8421432) | |
# The issues are returned as codes | |
example_duplicates <- map_df(keys, | |
function(x) | |
rgbif::name_usage(x, return ="data") | |
) | |
# Table codes, issues, descriptions | |
issues_df <- rgbif::name_issues() | |
example_duplicates_with_issues <- example_duplicates %>% | |
separate_rows(issues, sep = ",") %>% | |
left_join(issues_df, by = c("issues" = "code")) %>% | |
mutate(issues = issue) %>% | |
select(-c(issue, description)) %>% | |
group_by_at(vars(-issues)) %>% | |
summarise(issues = paste(issues, collapse = ",")) %>% | |
ungroup() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment