Does anyone know an R function that will return the number of items in a list?

0 votes

To count the number of objects in a list, you can use the **length **function as follows:

List with one element:

list1 <- list (1:20)

length (list1)

[1] 1

Length of the first element of the list:

length (list1[[1]])

[1] 20

List with three elements:

mylist <- list(r1=c(1:10),r2=c(1:5),r3=c(1:2))

> length(mylist)

[1] 3