Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in R Programming by (7.3k points)

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

1 Answer

0 votes
by

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

Related questions

0 votes
2 answers
0 votes
1 answer
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...