Learn R Programming

turner (version 0.1.9)

lengths: Length of each element within a list

Description

Get the length of the elements contained in a list.

Usage

lengths(alist, out = "vector")

Value

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

alist

Arguments

alist

a list

out

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

Author

Gaston Sanchez

See Also

length, funlist

Examples

Run this code
# 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)

# length of each vector (output in list format)
lengths(some_list, out = 'list')

# compare to 'length()'
length(some_list)

Run the code above in your browser using DataLab