Skip to content

Commit

Permalink
Update get_status.R
Browse files Browse the repository at this point in the history
  • Loading branch information
8Ginette8 committed Mar 19, 2024
1 parent 123d619 commit ef9d8d0
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions R/get_status.R
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,15 @@ 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(NA)
return(data.frame(NULL))

} else {
s.keep = bone.search[bone.search$rank%in%c("SPECIES","SUBSPECIES","VARIETY"),]
s.keep = s.keep[s.keep$status%in%c("ACCEPTED","SYNONYM"),]
s.keep = s.keep[s.keep$matchType%in%"EXACT",]
if (nrow(s.keep)==0){
cat("Not match found...","\n")
return(NA)
return(data.frame(NULL))

} else if (nrow(s.keep)>1){

Expand Down Expand Up @@ -150,7 +150,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(NA)
return(data.frame(NULL))

} else {
bone.search = bone.search[1,]
Expand All @@ -161,12 +161,12 @@ get_status=function(sp_name = NULL,

if (bone.search$matchType%in%"NONE") {
cat("No species name found...","\n")
return(NA)
return(data.frame(NULL))
}

if (bone.search$confidence[1]<conf_match) {
cat("Confidence match not high enough...","\n")
return(NA)
return(data.frame(NULL))
}

# Extract key of accepted name
Expand Down Expand Up @@ -197,7 +197,7 @@ get_status=function(sp_name = NULL,
all.version = lapply(all.key,function(x){
out = suppressWarnings(rgbif::name_usage(x,data="related")$data$scientificName)
if (is.null(out)){
return(NA)
return(NULL)
} else {
return(data.frame(key=x,scientificName=out))
}
Expand All @@ -211,7 +211,7 @@ get_status=function(sp_name = NULL,

# Conditions for synonymy
s.n = try(suppressWarnings(syn.syn[,c("key","scientificName")]),silent=TRUE)
if (class(s.n)[1]%in%"try-error") {s.n = data.frame(key=NA,scientificName=NA)}
if (class(s.n)[1]%in%"try-error") {s.n = data.frame(key=NULL,scientificName=NULL)}
all.names = rbind(a.n,s.n,c.n,r.n)

# Specific columns
Expand Down

0 comments on commit ef9d8d0

Please sign in to comment.