Package 'unpack'

Title: Assign Vectors Elements to Separate Variables
Description: Syntactic sugar to allow unpacking elements from a vector into separate variables in a single assignment expression.
Authors: Konrad Rudolph [aut, cre]
Maintainer: Konrad Rudolph <[email protected]>
License: MIT + file LICENSE
Version: 0.0.0.9000
Built: 2024-07-17 11:30:08 UTC
Source: https://github.com/klmr/unpack

Help Index


Unpack values

Description

The syntax c[...] = value unpacks the vector or list value into as many separate variables, specified as ..., as there are items.

Usage

c[...] = value

Arguments

...

variable names to assign to.

value

vector or list to unpack.

Details

The number of names in ... must match length(value). If there are too few or too many names, an error is raised.

An exception is made when the last name in ... is an index-less subset expression, i.e. name[]. In that case, the first N-1 elements from value are assigned to the first N-1 variable names, and the remaining elements are assigned to name.