| vector2array | R Documentation |
vector2array() turns a vector into an array,
with a specific vector orientation,
and turning the names into dimnames, and keeping (or forcing) broadcaster attribute.
undim() returns a copy of an object, but with its dimensions removed,
but still trying to keep the names if possible
(it somewhat is like the dimensional version of unlist()).
undim() will also keep (or force) the broadcaster attribute
array2vector() is an alias for undim().
vector2array(x, orient, ndim = orient, broadcaster = NULL)
undim(x, broadcaster = NULL)
array2vector(x, broadcaster = NULL)
x |
an vector (for |
orient |
a positive integer scalar, giving the orientation of the vector. |
ndim |
the number of dimensions in total. |
broadcaster |
|
For vector2array():
If x is already an array, x is returned unchanged.
Otherwise, given out <- vector2array(x, orient, ndim),
out will be an array with the following properties:
ndim(out) == ndim;
dim(out)[orient] == length(x), and all other dimensions will be 1;
dimnames(out)[[orient]] == names(x), and all other dimnames will be NULL.
For undim():
If x is not an array, x is returned unchanged.
Otherwise, a copy of the original object, but without dimensions,
but keeping names and broadcaster attribute as far as possible.
x <- setNames(1:27, c(letters, NA))
print(x)
y <- vector2array(x, 1L, 3L)
print(y)
undim(y)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.