list - R:计算列表中对象的数量

标签 list r count

有人可以推荐一个函数,可以让我计算并返回列表中的项目数吗?

library(stringr)

l <- strsplit(words, "a")

if(# number of items in list l < 1) 
  next

最佳答案

length(x)

Get or set the length of vectors (including lists) and factors, and of any other R object for which a method has been defined.

lengths(x)

Get the length of each element of a list or atomic vector (is.atomic) as an integer or numeric vector.

关于list - R:计算列表中对象的数量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1740524/

相关文章:

java - JAVA如何根据某些参数返回列表中对象出现的次数

javascript - JS RegExp 匹配条目计数

mysql - SQL限制+计数

java - 将 List<Object> 转换为 String 返回空结果

python-3.x - 按名称对字典列表进行排序并分配新键

r - 不想显示 ggplot2 中小刻度的所有标签

r - 根据同一数据框中的条件生成其他行

Python猜谜游戏,统计猜测次数

list - Kotlin - 列表过滤中的列表

r - 孤儿包裹礼仪