Skip to content

Commit

Permalink
fix to name_parse so that authority builds properly with basionym bra…
Browse files Browse the repository at this point in the history
…ckets
  • Loading branch information
stevenpbachman committed Jun 14, 2024
1 parent 93bd920 commit bf69f13
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions R/name_search_gbif.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,27 @@ name_search_gbif = function(name,

#Check if the 'scientificName' column contains NA values
if (!is.na(results$scientificName)) {
gen_sp_auth <- rgbif::name_parse(results$scientificName) %>%
dplyr::select(genusorabove, specificepithet, authorship) %>%
gen_sp_auth <- rgbif::name_parse(results$scientificName)

# Check if the 'bracketAuthorship' column exists
if ("bracketauthorship" %in% colnames(gen_sp_auth)) {
# Create 'taxonomicAuthority' by concatenating 'authorship' and 'bracketAuthorship'
gen_sp_auth <- gen_sp_auth %>%
dplyr::mutate(taxonomicAuthority = paste(paste0("(", bracketauthorship, ")"), authorship, sep = " ")) %>%
dplyr::select(genusorabove, specificepithet, taxonomicAuthority)
} else {
# Use 'authorship' as 'taxonomicauthority'
gen_sp_auth <- gen_sp_auth %>%
dplyr::mutate(taxonomicAuthority = authorship) %>%
dplyr::select(genusorabove, specificepithet, taxonomicAuthority)
}
# Rename columns
gen_sp_auth <- gen_sp_auth %>%
dplyr::rename(
genus = genusorabove,
species = specificepithet,
taxonomicAuthority = authorship
species = specificepithet
)

#results <- results %>% dplyr::select(-genus, -species, -taxonomicAuthority)
results <- dplyr::bind_cols(results, gen_sp_auth)
}
Expand Down

0 comments on commit bf69f13

Please sign in to comment.