Skip to content

Commit

Permalink
Reducing duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
dfalster committed Jul 26, 2023
1 parent 7d4ae8f commit b9af2d8
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions R/clean_names.R
Original file line number Diff line number Diff line change
Expand Up @@ -569,24 +569,19 @@ get_updated_species_list <-
aligned_data$aligned_name %>% update_taxonomy(resources = resources, output = output)

if (one_to_many %in% c("return_all", "collapse_to_higher_taxon")) {
aligned_data %>%
dplyr::select(original_name, aligned_name, aligned_reason) %>%
dplyr::left_join(aligned_species_list_tmp,
by = c("aligned_name"),
multiple = "all") %>%
dplyr::filter(!is.na(taxonIDClean)) %>%
dplyr::mutate(genus = stringr::word(canonicalName, 1, 1)) %>%
dplyr::rename(canonical_name = canonicalName)
multiple = "all"
} else {
aligned_data %>%
dplyr::select(original_name, aligned_name, aligned_reason) %>%
dplyr::left_join(aligned_species_list_tmp,
by = c("aligned_name"),
multiple = "first") %>%
dplyr::filter(!is.na(taxonIDClean)) %>%
dplyr::mutate(genus = stringr::word(canonicalName, 1, 1)) %>%
dplyr::rename(canonical_name = canonicalName)
multiple = "first"
}

aligned_data %>%
dplyr::select(original_name, aligned_name, aligned_reason) %>%
dplyr::left_join(aligned_species_list_tmp,
by = c("aligned_name"),
multiple = multiple) %>%
dplyr::filter(!is.na(taxonIDClean)) %>%
dplyr::mutate(genus = stringr::word(canonicalName, 1, 1)) %>%
dplyr::rename(canonical_name = canonicalName)
}


Expand Down

0 comments on commit b9af2d8

Please sign in to comment.