Package rWCVP version 1.2.4
解决方法直接看Solution。
wcvp_checklist(
taxon = NULL,
taxon_rank = c("species", "genus", "family", "order", "higher"),
area_codes = NULL,
synonyms = TRUE,
render_report = FALSE,
native = TRUE,
introduced = TRUE,
extinct = TRUE,
location_doubtful = TRUE,
hybrids = FALSE,
infraspecies = TRUE,
report_filename = NULL,
report_dir = NULL,
report_type = c("alphabetical", "taxonomic"),
wcvp_names = NULL,
wcvp_distributions = NULL
)
wcvp_checklist()的参数介绍和使用方法见下列文章:
当向参数【taxon】传入了物种的完整科学名,同时根据参数介绍和函数的使用说明,向参数【taxon】传入了 species,返回的结果很令人意外!
以 wcvp_names 中的第一条数据为例,查看它的科学名和分类等级:
library(rWCVP)
library(rWCVPdata)
wcvp_names[1,]['taxon_name']
wcvp_names[1,]['taxon_rank']
# A tibble: 1 × 1
taxon_name
1 Elymus czimganicus
# A tibble: 1 × 1
taxon_rank
1 Species
好的,现在已经知道 Elymus czimganicus 是一个物种的科学名,那么尝试用 wcvp_checklist() 拿到 Elymus czimganicus 的记录数据:
wcvp_checklist(taxon = "Elymus czimganicus", taxon_rank = "species")
这个结果是不可接受的!数据就在那里,wcvp_checklist() 查不出来也太膈应人了!
查看源代码后,发现:将 "species" 传递给参数【taxon_rank】后,wcvp_checklist() 尝试在 wcvp_names 的 species 列中检索包含 "Elymus czimganicus" 字符串的记录,问题在于 wcvp_names 的 species 列只是种加词,而不是标准的属名+种加词。
直接查看wcvp_names 的 species 列就水落石出了:
wcvp_names[,"species"]
# A tibble: 1,422,868 × 1
species
1 czimganicus
2 gracilis
3 sempervivoideum
4 tenuiflora
5 tenuiflora
6 tenuiflorus
7 comosum
8 ripogonum
9 graminea
10 arborescens
# ℹ 1,422,858 more rows
# ℹ Use `print(n = ...)` to see more rows
也就是说,在 wcvp_names 的 species 列中永远也查找不到 "Elymus czimganicus" 字符串。
那么,如果要让wcvp_checklist()可以运行的思路来分析,想要查找 "Elymus czimganicus" ,只能向参数【taxon】传入它的种加词,即 "czimganicus"。但是不难想到,种加词在不同的属中是可能重复的,也就是说在 wcvp_names 的 species 列中很有可能查找到多个包含 "czimganicus" 的记录。下面来验证一下:
wcvp_checklist(taxon = "czimganicus", taxon_rank = "species")
ℹ No area specified. Generating global checklist.
# A tibble: 9 × 43
plant_name_id ipni_id taxon_rank taxon_status family genus_hybrid genus
1 411059 400227-1 Species Accepted Poaceae NA Elymus
2 411059 400227-1 Species Accepted Poaceae NA Elymus
3 411059 400227-1 Species Accepted Poaceae NA Elymus
4 411059 400227-1 Species Accepted Poaceae NA Elymus
5 411059 400227-1 Species Accepted Poaceae NA Elymus
6 411059 400227-1 Species Accepted Poaceae NA Elymus
7 411059 400227-1 Species Accepted Poaceae NA Elymus
8 2523629 712564-1 Species Accepted Ranunculaceae NA Ranuncul…
9 2523629 712564-1 Species Accepted Ranunculaceae NA Ranuncul…
# ℹ 36 more variables: species_hybrid , species ,
# infraspecific_rank , infraspecies , parenthetical_author ,
# primary_author , publication_author , place_of_publication ,
# volume_and_page , first_published , nomenclatural_remarks ,
# geographic_area , lifeform_description , climate_description ,
# taxon_name , taxon_authors , accepted_plant_name_id ,
# accepted_name , basionym_plant_name_id , …
果然不出所料,除了 "Elymus czimganicus" 的记录外,起码还包含了 Ranunculaceae 物种的记录,虽然可以手动清楚这些记录。但如果要查找的物种很多,或者种加词太普遍的话,返回的结果就会让人难以招架!
那么,在 wcvp_names 的哪一列中可以查找到 "Elymus czimganicus" 字符串呢?答案是:"taxon_name" 列。
所以,在不改动源代码(考虑到其他函数)和开发者修复之前,我们可以将"taxon_name" 列的值复制到 "species" 列即可。
wcvp_checklist(taxon = "Elymus czimganicus", taxon_rank = "species", wcvp_names = wcvp_names)
ℹ No area specified. Generating global checklist.
# A tibble: 7 × 43
plant_name_id ipni_id taxon_rank taxon_status family genus_hybrid genus
1 411059 400227-1 Species Accepted Poaceae NA Elymus
2 411059 400227-1 Species Accepted Poaceae NA Elymus
3 411059 400227-1 Species Accepted Poaceae NA Elymus
4 411059 400227-1 Species Accepted Poaceae NA Elymus
5 411059 400227-1 Species Accepted Poaceae NA Elymus
6 411059 400227-1 Species Accepted Poaceae NA Elymus
7 411059 400227-1 Species Accepted Poaceae NA Elymus
# ℹ 36 more variables: species_hybrid , species ,
# infraspecific_rank , infraspecies , parenthetical_author ,
# primary_author , publication_author , place_of_publication ,
# volume_and_page , first_published , nomenclatural_remarks ,
# geographic_area , lifeform_description , climate_description ,
# taxon_name , taxon_authors , accepted_plant_name_id ,
# accepted_name , basionym_plant_name_id , …