As Pierre mentioned, NCBI is a good resource for this kind of transformation.
You can still use taxize
to perform the conversion:
library("taxize")
species <- c('Helianthus annuus', 'Mycobacterium bovis', 'Rattus rattus', 'XX', 'Mus musculus')
uids <- get_uid(species)
# keep only uids which you have in the database
uids.found <- as.uid(uids[!is.na(uids)])
# keep only species names corresponding to your ids
species.found <- species[!is.na(uids)]
common.names <- sci2comm(uids.found, db = 'ncbi')
names(common.names) <- species.found
common.names
## output:
## $`Helianthus annuus`
## [1] "common sunflower"
##
## $`Mycobacterium bovis`
## character(0)
##
## $`Rattus rattus`
## [1] "black rat"
##
## $`Mus musculus`
## [1] "house mouse"
This works correctly if no common name is available, or if there is no species in the database. You can also try a different database, e.g. db='itis'
.
The advantage of this approach is that you do not have to parse a file yourself. The downside is that it can be slow for large list, since for every species a database request is performed.