R:计数列表中的对象数 [英] R: Count number of objects in list

查看:56
本文介绍了R:计数列表中的对象数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以推荐一个可以让我计数并返回列表中项目数量的功能吗?

Can someone recommend a function that can allow me to count and return the number of items in a list?

library(stringr)

l <- strsplit(words, "a")

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

推荐答案

长度(x)

获取或设置向量(包括列表)和因子以及定义了方法的任何其他R对象的长度.

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

长度(x)

以整数或数值向量的形式获取列表或原子向量(is.atomic)的每个元素的长度.

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

这篇关于R:计数列表中的对象数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆