a2v {str2str} | R Documentation |
(3D+) Array to (Atomic) Vector
Description
a2v
converts a matrix to a (atomic) vector. The benefit of m2v
over as.vector
or c
is that 1) the vector can be formed along rows
any sequence of dimensions and 2) the dimnames from a
can be used for
the names of the returned vector.
Usage
a2v(a, along = ndim(a):1, use.dimnames = TRUE, sep = "_", check = TRUE)
Arguments
a |
3D+ array. |
along |
numeric vector of length = |
use.dimnames |
logical vector of length 1 that specifies whether the dimnames
of |
sep |
character vector of length 1 specifying the string that will separate
the dimnames from each dimension in the naming scheme of the return object. Note,
|
check |
logical vector of length 1 specifying whether to check the structure
of the input arguments. For example, check whether |
Value
(atomic) vector of length = length(a)
where the order of elements
from a
has been determined by along
and the names determined by
the use.dimnames
, dimnames(a)
, and sep
.
Examples
a2v(HairEyeColor) # layers, then columns, then rows (default)
a2v(HairEyeColor, along = c(3,1,2)) # layers, then rows, then columns
a2v(HairEyeColor, along = 1:3) # rows, then columns, then layers
a2v(HairEyeColor, along = 1:3, use.dimnames = FALSE)