I have a list of species (about 2000) that I want to verify : synonyms, spelling, recent names etc.
Here is a subset :
data <- c("Abalistes stellatus", "Abudefduf abdominalis", "Abudefduf bengalensis", "Abudefduf concolor", "Abudefduf conformis", "Abudefduf luridus", "Abudefduf notatus", "Abudefduf saxatilis", "Abudefduf septemfasciatus", Abudefduf sexfasciatus", "Abudefduf sordidus", "Abudefduf sparoides", "Abudefduf troschelii", "Abudefduf vaigiensis", "Abudefduf whitleyi", "Acanthaluteres brownii", "Acanthaluteres spilomelanurus", "Acanthaluteres vittiger", "Acanthemblemaria crockeri" ,"Acanthemblemaria hancocki", "Acanthemblemaria spinosa", "Acanthistius cinctus", "Acanthistius ocellatus", "Acanthistius pardalotus", "Acanthistius patachonicus" ,"Acanthistius sebastoides", "Acanthistius serratus", "Acanthochromis polyacanthus", "Acanthopagrus australis", "Acanthopagrus latus", "Acanthostracion polygonius", "Acanthostracion quadricornis", "Acanthurus achilles", "Acanthurus albipectoralis", "Acanthurus auranticavus", "Acanthurus bahianus", "Acanthurus bariene", "Acanthurus blochii", "Acanthurus chirurgus", "Acanthurus coeruleus", "Acanthurus dussumieri", "Acanthurus fowleri", "Acanthurus gahhm", "Acanthurus grammoptilus", "Acanthurus guttatus", "Acanthurus leucocheilus", "Acanthurus leucopareius", "Acanthurus leucosternon", "Acanthurus lineatus" ,"Acanthurus maculiceps")
I search corresponding names in the COL (Catalogue of Life) database with the following function :
check_sp_name <- function(sp_list){
# takes a list of species name that we want to check
verified_names <- c()
for (i in 1:length(sp_list)) {
x <- NA
x <- col_search(name = sp_list[i])
x <- x[[1]]
if (nrow(x)==0) {
verified_names <- append(verified_names, "Non observation")
} else {
if (sum(x$status == "accepted name") != 0) {
y <- x$name[x$status == "accepted name"& x$rank == "species"]
} else if (sum(x$status == "synonym") != 0) {
y <- x$acc_name[x$status == "synonym"& x$rank == "species"]
} else if (sum(x$status == "provisionally accepted name") != 0) {
y <- x$name[x$status == "provisionally accepted name"& x$rank == "species"]
}
y <- ifelse(length(y) == 0, "infraspecies", y)
y <- ifelse(length(y) > 1, y[y == sp_list[i]], y)
verified_names <- append(verified_names, y) # list of verified species names
}
print(i)
}
verified_inputs <- data.frame(input_names = sp_list, output_names = verified_names)
return(verified_inputs)
}
Here is the problem : yesterday I tried the code and everything went find but this morning while I did change anything, I got this error :
Error in if (nrow(x) == 0) { : argument is of length zero
In addition: Warning message:
COL taxon not found
I tried the line that fills x alone and it worked... In addition, the error doesn't occur at the same iteration each time... I've been struggling with this all day.
One hypothesis I have is that the COL website isn't stable right now. Indeed, a message is displayed on the front page : https://www.catalogueoflife.org/
Can it be why I get this error?
Does someone have an idea to bypass it?
Also I have to mention that I tried using the GBIF database but it is not as uptodate as COL is.
Thank you for your help