zip: Aggregate vectors/lists into lists of lists

View source: R/zip.R

zipR Documentation

Aggregate vectors/lists into lists of lists

Description

This function emulates Python's zip function. It expects a variable number of arguments. If a single vector/list x is passed the return value is a list of lists where each sub-list contains the components “key” and “value”. If x is named the key is the name, otherwise it is the element number. The value field unsuprisingly contains the corresponding value.

Usage

zip(...)

Arguments

...

[Lists/vectors]
A variable number of lists or vectors of the same size.

Value

A list of lists.

Examples

x = list("a" = 1, "b" = 2, "c" = 3)
for (el in zip(x)) {
  catf("Key: '%s', Value: %i\n", el$key, el$value)
}

z = zip(x, x)

jakobbossek/re documentation built on Nov. 15, 2024, 1:42 a.m.