enumerateit | R Documentation |
This function pairs elements of vectors or lists with their indices. The
output
is meant to be used in a for loop, and each element extracted with the
ind()
, val()
, or val1()
functions. A slightly lighter weight
alternative to itertools::enumerate()
enumerateit(..., zeroIndexed = FALSE)
... |
Vectors or lists to be enumerated. |
zeroIndexed |
A logical indicating whether indexing should start from zero. Default is FALSE. |
A list of lists, where each inner list contains an index and the corresponding elements from the input vectors or lists.
ind()
, val()
, val1()
# Enumerate a vector
enumerateit(c("a", "b", "c"))
# Enumerate a vector starting from zero
enumerateit(c("a", "b", "c"), zero_indexed = TRUE)
# Enumerate two vectors
enumerateit(c(1, 2), c("x", "y"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.