Get the length of the elements contained in a list.

lengths(alist, out = "vector")

Arguments

alist

a list

out

string indicating the format of the output ("vector" or "list")

Value

A vector (or list) with the lengths of the elements in

alist

Author

Gaston Sanchez

See also

Examples

# say you have some list
some_list = list(1:3, 4:5, 6:9)

# length of each vector (output in vector format)
lengths(some_list)
#> [1] 3 2 4

# length of each vector (output in list format)
lengths(some_list, out = 'list')
#> [[1]]
#> [1] 3
#> 
#> [[2]]
#> [1] 2
#> 
#> [[3]]
#> [1] 4
#> 

# compare to 'length()'
length(some_list)
#> [1] 3