enumerate: Create an enumeration object

Description Usage Arguments Examples

Description

Create an iterator that iterates over an iterable, returning the value in a list that includes an index.

Usage

1
enumerate(iterable)

Arguments

iterable

Iterable to iterate over.

Examples

1
2
# Create an enumeration of five random numbers
as.list(enumerate(rnorm(5)))

Example output

Loading required package: iterators
[[1]]
[[1]]$index
[1] 1

[[1]]$value
[1] 0.9719456


[[2]]
[[2]]$index
[1] 2

[[2]]$value
[1] -0.3330728


[[3]]
[[3]]$index
[1] 3

[[3]]$value
[1] -1.117844


[[4]]
[[4]]$index
[1] 4

[[4]]$value
[1] 0.7948293


[[5]]
[[5]]$index
[1] 5

[[5]]$value
[1] 0.1508827

itertools documentation built on May 2, 2019, 2:26 p.m.