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
相关推荐
喜欢喝果茶.7 分钟前
QOverload<参数列表>::of(&函数名)信号槽
开发语言·qt
亓才孓8 分钟前
[Class类的应用]反射的理解
开发语言·python
努力学编程呀(๑•ี_เ•ี๑)8 分钟前
【在 IntelliJ IDEA 中切换项目 JDK 版本】
java·开发语言·intellij-idea
小镇敲码人17 分钟前
深入剖析华为CANN框架下的Ops-CV仓库:从入门到实战指南
c++·python·华为·cann
island131430 分钟前
CANN GE(图引擎)深度解析:计算图优化管线、内存静态规划与异构任务的 Stream 调度机制
开发语言·人工智能·深度学习·神经网络
坚持就完事了34 分钟前
Java中的集合
java·开发语言
摘星编程36 分钟前
深入理解CANN ops-nn BatchNormalization算子:训练加速的关键技术
python
魔芋红茶38 分钟前
Python 项目版本控制
开发语言·python
lili-felicity44 分钟前
CANN批处理优化技巧:从动态批处理到流水线并行
人工智能·python
一个有梦有戏的人1 小时前
Python3基础:进阶基础,筑牢编程底层能力
后端·python