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
Built: 2024-07-17 11:30:08 UTC

Help Index

Unpack values


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


c[...] = value



variable names to assign to.


vector or list to unpack.


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.