v2lv {str2str} | R Documentation |
(Atomic) Vector to List of (Atomic) Vectors
Description
v2lv
converts a (atomic) vector to a list of atomic vectors. The default is
conversion to a list vector where each element of the list has only one element.
The n.break
argument allows for the input vector to be broken up into
larger sections with each section being a list element in the return object.
Usage
v2lv(v, use.names = TRUE, n.break = 1L, warn.break = TRUE, check = TRUE)
Arguments
v |
(atomic) vector. |
use.names |
logical vector of length 1 specifying whether the names from
|
n.break |
integer vector of length 1 specifying how |
warn.break |
logical vector of length one specifying whether a warning
should be printed if |
check |
logical vector of length 1 specifying whether to check the structure
of the input arguments. For example, check whether |
Details
Future versions of this function plan to allow for use similar to the utils::relist
function to allow reconstruction after flattening a matrix-like object to a single vector.
Value
list of (atomic) vectors that are the elements of v
broken up
according to n.break
. The list only has names if v
has names and
n.break
= 1L.
Examples
vec <- setNames(object = mtcars[[1]], nm = row.names(mtcars))
v2lv(vec)
v2lv(vec, use.names = FALSE)
vec <- unlist(mtcars)
v2lv(vec, n.break = 32) # n.break > 1L and multiple of length(v)
v2lv(vec, n.break = 30) # n.break > 1L and NOT multiple of length(v)