relist a vector which allows re-ordered names

relist_named(x, skeleton, ...)

Arguments

x

vector to be applied to the skeleton list structure in order.

skeleton

list object representing the desired final list structure, or vector when the input data x should be returned as-is, without change. Specifically, when skeleton is a vector, the names(x) are maintained without change.

...

additional arguments are ignored.

Value

list object with the same structure as the skeleton.

Details

This function is a simple update to utils::relist() that allows updating the names of each list element. More specifically, this function does not replace the updated names with the corresponding names from the list skeleton, as is the case in utils:::relist.default().

It is somewhat surprising that utils::relist() is simply a nested for loop, instead of rapply() or some fancy vectorized alternative. That said, the function works, and there is much to be commended for functions that work.

See also

Other jam list functions: cPasteSU(), cPasteS(), cPasteUnique(), cPasteU(), cPaste(), heads(), jam_rapply(), list2df(), mergeAllXY(), mixedSorts(), rbindList(), rlengths(), sclass(), sdim(), uniques(), unnestList()