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
相关推荐
djjdjdjdjjdj13 分钟前
如何用参数解构在函数入口处直接提取对象属性
jvm·数据库·python
MegaDataFlowers14 分钟前
调用Service层操作数据
java·开发语言
forEverPlume25 分钟前
mysql如何批量增加表的字段_脚本化DDL操作实践
jvm·数据库·python
asdzx6729 分钟前
使用 Python 读取 PDF: 提取文本和图片
开发语言·python·pdf
沐知全栈开发34 分钟前
jQuery Mobile 表单选择
开发语言
m0_5964063735 分钟前
CSS如何高效引入样式表_对比link标签与import指令的性能差异
jvm·数据库·python
MoonBit月兔44 分钟前
MoonBit 大型软件合成挑战赛决赛暨 Meetup 0.9 版本专场回顾
大数据·开发语言·人工智能·moonbit
宣宣猪的小花园.1 小时前
C语言重难点全解析:指针到内存四区
c语言·开发语言
南宫萧幕1 小时前
HEV 智能能量管理实战:从 MPC/PPO 理论解析到 Python-Simulink 联合仿真闭环全流程
开发语言·python·算法·matlab·控制
码农的神经元1 小时前
Python 实现县域变电站智能巡检与抢修调度:地图、路径规划与恢复策略
开发语言·python