R语言【taxa】——leaves()和n_leaves():每个分类群的冠群和冠群数量

Package taxa version 0.4.2


leaves(x, value = NULL, ...)

获取每个分类单元的冠群索引或其他每个分类单元的值。leaves 是没有下级分类群的分类群。

参数【x】:获取 leaves 的对象,比如 taxonomy。

参数【value】:要返回的东西,而不是索引。长度必须与分类群数相同。

参数【...】:其余参数。

复制代码
> x <- taxonomy(c('Carnivora', 'Felidae', 'Panthera', 'Panthera leo',
+                 'Panthera tigris', 'Ursidae', 'Ursus', 'Ursus arctos'),
+               supertaxa = c(NA, 1, 2, 3, 3, 1, 6, 7))
复制代码
<taxonomy[8]>
1: Carnivora
├─2: Felidae
│ └─3: Panthera
│   ├─4: Panthera leo
│   └─5: Panthera tigris
└─6: Ursidae
  └─7: Ursus
    └─8: Ursus arctos
复制代码
> leaves(x)
[[1]]
[1] 4 5 8

[[2]]
[1] 4 5

[[3]]
[1] 4 5

[[4]]
integer(0)

[[5]]
integer(0)

[[6]]
[1] 8

[[7]]
[1] 8

[[8]]
integer(0)
复制代码
> leaves(x, value = tax_name(x))
[[1]]
[1] "Panthera leo"    "Panthera tigris" "Ursus arctos"   

[[2]]
[1] "Panthera leo"    "Panthera tigris"

[[3]]
[1] "Panthera leo"    "Panthera tigris"

[[4]]
character(0)

[[5]]
character(0)

[[6]]
[1] "Ursus arctos"

[[7]]
[1] "Ursus arctos"

[[8]]
character(0)

n_leaves(x)

获取每个分类群的 leaves 数量。

复制代码
> x <- taxonomy(c('Carnivora', 'Felidae', 'Panthera', 'Panthera leo',
+                 'Panthera tigris', 'Ursidae', 'Ursus', 'Ursus arctos'),
+               supertaxa = c(NA, 1, 2, 3, 3, 1, 6, 7))
> n_leaves(x)
[1] 3 2 2 0 0 1 1 0
相关推荐
倔强青铜三1 分钟前
苦练Python第41天:如何用dir() 函数“透视一切”
人工智能·python·面试
倔强青铜三6 分钟前
苦练Python第40天:模块加载与项目组织,让代码像乐高一样可复用!
人工智能·python·面试
跟橙姐学代码1 小时前
Python 集合:人生中最简单的真理,只有一次
前端·python·ipython
偷心伊普西隆1 小时前
Python Excel 通用筛选函数
python·excel·pandas
Warren981 小时前
Spring Boot 整合网易163邮箱发送邮件实现找回密码功能
数据库·vue.js·spring boot·redis·后端·python·spring
CodeCraft Studio2 小时前
Excel处理控件Aspose.Cells教程:使用Python将 Excel 转换为 NumPy
python·excel·numpy·aspose·数据表格·aspose.cells·excel文档格式转换
秦禹辰2 小时前
本地Docker部署开源Web相册图库Piwigo与在线远程访问实战方案
开发语言·后端·golang
一粒马豆2 小时前
chromadb使用hugging face模型时利用镜像网站下载注意事项
python·embedding·chroma·词嵌入·hugging face·词向量·chromadb
the beard2 小时前
深入理解Java多线程:状态、安全、同步与通信
java·开发语言
zhysunny2 小时前
Day22: Python涡轮增压计划:用C扩展榨干最后一丝性能!
c语言·网络·python