From fd558afd79f000b38233723ede1970dd76978afd Mon Sep 17 00:00:00 2001 From: Carl Boettiger Date: Wed, 1 Apr 2015 11:55:20 -0700 Subject: [PATCH] collapse valid_names to string and warn on no match found. #38 --- R/synonyms.R | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/R/synonyms.R b/R/synonyms.R index 2cff052..bd7e986 100644 --- a/R/synonyms.R +++ b/R/synonyms.R @@ -71,7 +71,10 @@ validate_names <- function(species_list, limit = 50, server = SERVER){ syn_table <- dplyr::filter_(syn_table, .dots = list(~Synonymy != "misapplied name")) } code <- unique(syn_table$SpecCode) - + + if(is.null(code)) + warning(paste0("No match found for species '", x, "'")) + ## Return the name listed as valid. ## Nope; doesn't work. eg. because the valid name for "Auxis rochei" is "Auxis rochei rochei", ## but a syn_table doesn't return any valid name, only the spec code. @@ -83,6 +86,7 @@ validate_names <- function(species_list, limit = 50, server = SERVER){ speciesnames(code) }) - unname(out) + ## sapply will still return nested lists if a value is missing + unname(unlist(out)) }