Skip to content

Commit

Permalink
adding check on resources to all functions that need resources
Browse files Browse the repository at this point in the history
  • Loading branch information
wcornwell committed Jul 31, 2024
1 parent 98d8921 commit a99fc67
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions R/create_species_state_origin_matrix.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
#'
#'
create_species_state_origin_matrix <- function(resources = load_taxonomic_resources()) {
if(is.null(resources)){
message("Not finding taxonomic resources; check internet connection?")
return(NULL)
}

apc_species <- filter_data_to_accepted_species(resources)
sep_state_data <- separate_states(apc_species)
apc_places <- identify_places(sep_state_data)
Expand Down
5 changes: 5 additions & 0 deletions R/create_taxonomic_update_lookup.R
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@ create_taxonomic_update_lookup <- function(taxa,
resources = load_taxonomic_resources(),
quiet = FALSE,
output = NULL) {

if(is.null(resources)){
message("Not finding taxonomic resources; check internet connection?")
return(NULL)
}

validate_taxonomic_splits_input(taxonomic_splits)

Expand Down
5 changes: 5 additions & 0 deletions R/match_taxa.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ match_taxa <- function(
identifier = NA_character_
) {

if(is.null(resources)){
message("Not finding taxonomic resources; check internet connection?")
return(NULL)
}

update_na_with <- function(current, new) {
ifelse(is.na(current), new, current)
}
Expand Down
5 changes: 5 additions & 0 deletions R/native_anywhere_in_australia.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ native_anywhere_in_australia <- function(species, resources = load_taxonomic_res
# Create lookup tables
full_lookup <- create_species_state_origin_matrix(resources = resources)

if(is.null(resources)){
message("Not finding taxonomic resources; check internet connection?")
return(NULL)
}

if (any(!species %in% full_lookup$species)) {
warning("At least one input not found in APC; make sure inputs are at the species level and consider using `create_taxonomic_update_lookup` first.")
}
Expand Down

0 comments on commit a99fc67

Please sign in to comment.