diff --git a/R/get_status.R b/R/get_status.R index 6474160..c6ed413 100644 --- a/R/get_status.R +++ b/R/get_status.R @@ -66,6 +66,18 @@ get_status=function(sp_name = NULL, stop("Given 'sp_name' is NA or NULL, a string must be provided...") } + # Empty output + e.output = data.frame(canonicalName = NA, + rank = NA, + gbif_key = NA, + scientificName = NA, + gbif_status = NA, + Genus = NA, + Family = NA, + Order = NA, + Phylum = NA, + IUCN_status = NA) + # Search if (!search){ # Search input name via fuzzy match and direct search @@ -114,7 +126,7 @@ get_status=function(sp_name = NULL, if (nrow(bone.search)>1){ if (all(!bone.search$rank%in%c("SPECIES","SUBSPECIES","VARIETY"))){ cat("Not match found...","\n") - return(data.frame(NULL)) + return(e.output) } else { s.keep = bone.search[bone.search$rank%in%c("SPECIES","SUBSPECIES","VARIETY"),] @@ -122,7 +134,7 @@ get_status=function(sp_name = NULL, s.keep = s.keep[s.keep$matchType%in%"EXACT",] if (nrow(s.keep)==0){ cat("Not match found...","\n") - return(data.frame(NULL)) + return(e.output) } else if (nrow(s.keep)>1){ @@ -156,7 +168,7 @@ get_status=function(sp_name = NULL, s.usp = length(unique(bone.search$speciesKey))==1 if (!s.usp){ cat("No synonyms distinction could be made. Consider using phylum/class/order/family...","\n") - return(data.frame(NULL)) + return(e.output) } else { bone.search = bone.search[1,] @@ -167,12 +179,12 @@ get_status=function(sp_name = NULL, if (bone.search$matchType%in%"NONE") { cat("No species name found...","\n") - return(data.frame(NULL)) + return(e.output) } if (bone.search$confidence[1]