lengths: Length of each element within a list

Description Usage Arguments Value Author(s) See Also Examples

View source: R/lengths.r

Description

Get the length of the elements contained in a list.

Usage

1
  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(s)

Gaston Sanchez

See Also

length, funlist

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# 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)

Example output

Attaching package: 'turner'

The following object is masked from 'package:base':

    lengths

[1] 3 2 4
[[1]]
[1] 3

[[2]]
[1] 2

[[3]]
[1] 4

[1] 3

turner documentation built on May 2, 2019, 8:35 a.m.