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
相关推荐
2301_781571422 小时前
JavaScript中Object-getOwnPropertySymbols获取方法
jvm·数据库·python
skywalk81632 小时前
Trae生成的中文编程语言关键字(如“定“、“函“、“印“等)需要和标识符之间用 空格 隔开,以确保正确识别
服务器·开发语言·编程
红色的小鳄鱼2 小时前
前端面试js手写
开发语言·前端·javascript
海盗12342 小时前
C#中的IEqualityComparer<T>使用
开发语言·c#
江公望2 小时前
Qt QSharedPointer用法,10分钟讲清楚
开发语言·qt
倒霉熊dd2 小时前
Python学习(第一部分 语法与数据结构/核心基础)
大数据·python·学习·pip
月落归舟3 小时前
深入理解Java适配器模式,彻底搞懂设计思想
java·开发语言·适配器模式
Mr_pyx3 小时前
【LeetHOT100】二叉树的中序遍历——Java多解法详解
java·开发语言·深度优先
仅此,3 小时前
deep agent整合 DeepSeek 记录
python·langchain·agent·deep agent sdk
ftpeak3 小时前
AI开发之LangGraph教程6~自定义状态 (Custom State)
python·ai·langchain·langgraph