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 分钟前
ubantu中下载编译安装qt5.15.3
开发语言·qt
球求了32 分钟前
C++:继承机制详解
开发语言·c++·学习
weixin_贾44 分钟前
最新AI-Python机器学习与深度学习技术在植被参数反演中的核心技术应用
python·机器学习·植被参数·遥感反演
张槊哲1 小时前
函数的定义与使用(python)
开发语言·python
船长@Quant1 小时前
文档构建:Sphinx全面使用指南 — 实战篇
python·markdown·sphinx·文档构建
北辰浮光1 小时前
[Mybatis-plus]
java·开发语言·mybatis
光而不耀@lgy2 小时前
C++初登门槛
linux·开发语言·网络·c++·后端
lkbhua莱克瓦242 小时前
用C语言实现——一个中缀表达式的计算器。支持用户输入和动画演示过程。
c语言·开发语言·数据结构·链表·学习方法·交友·计算器
Mr__Miss2 小时前
面试踩过的坑
java·开发语言
偶尔微微一笑2 小时前
AI网络渗透kali应用(gptshell)
linux·人工智能·python·自然语言处理·编辑器