英文:
How can I fetch scientific name using common name in R?
问题
"get_scientific_name("avocado")
should result in c("Persea americana")
."
"Some of the relevant packages that I came across was rgbif and [taxize][2]
?"
"1: https://docs.ropensci.org/rgbif/"
"2: https://docs.ropensci.org/taxize/reference/index.html#the-plant-list"
"Specifically I am interested in names of crops."
英文:
E.g.
get_scientific_name("avacado")
should result in c("Persea americana")
.
Some of the relevant packages that I came across was rgbif and [taxize][2]
?
Specifically I am interested in names of crops.
答案1
得分: 2
你可以编写一个小包装器来解析taxize
包中pow_search
的结果:
get_scientific_name <- function(name) {
taxize::pow_search(name)$data$name[1]
}
对几种作物的通用名称进行测试似乎得到了合理的结果:
get_scientific_name('avocado')
#> [1] "Persea americana"
get_scientific_name('sweetcorn')
#> [1] "Zea mays"
get_scientific_name('carrot')
#> [1] "Daucus carota"
get_scientific_name('spelt')
#> [1] "Triticum spelta"
创建于2023-06-12,使用 reprex v2.0.2
英文:
You can write a little wrapper to parse the results from pow_search
in the taxize
package:
get_scientific_name <- function(name) {
taxize::pow_search(name)$data$name[1]
}
Testing on the common name of several crops seems to give sensible results:
get_scientific_name('avocado')
#> [1] "Persea americana"
get_scientific_name('sweetcorn')
#> [1] "Zea mays"
get_scientific_name('carrot')
#> [1] "Daucus carota"
get_scientific_name('spelt')
#> [1] "Triticum spelta"
<sup>Created on 2023-06-12 with reprex v2.0.2</sup>
答案2
得分: 0
根据 @Allan Cameron 的回答,taxize 包含了根据普通名称获取科学名称的函数。
taxize::comm2sci("avocado")
返回结果:
$avocado
[1] "Persea americana"
英文:
Expanding on @Allan Cameron's answer, taxize package has functions to get the scientific names based on common names.
taxize::comm2sci("avocado")
returns
$avocado
[1] "Persea americana"
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论