Description Usage Arguments Details Value Author(s) Examples
nameNd
ensures a given number of dimensions:
If a
has less than N
dimensions, new dimensions of length 1 are appended.
If a
has more than N
dimensions, the supernumerary dimensions are collapsed onto
the last dimension.
Attributes old.dim
and old.dimnames
are used by default. restoredim
is the
inverse of makeNd
.
1 2 3 4 5 6 7 8 9 10 11 |
a |
an array (matrix, vector) |
N |
the desired number of dimensions, 0 to remove the |
old |
list containing a list with (possibly) elements |
n |
how many makeNdim steps to go back? |
... |
ignored |
usedim |
use only the specified dimensions |
fromend |
if |
drop |
should 1d arrays drop to vectors? |
Note that missing attributes as well as old.dim = NULL
produce a (dimensionless)
vector. This is also the case if a
lost the old.*
attributes during
computations like as.numeric
, c
, etc..
fromend
together with numeric usedim
specifies dimensions counting from the
end. E.g. fromend = TRUE
and usedim = 1 : 3
for an array to be restored to 10d
means restoring dimensions 8 : 10. fromend = TRUE
and usedim = -(1 : 3)
restores
dimensions 1 to 7.
N-dimensional array
an array
Claudia Beleites
Claudia Beleites
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | v <- arrayhelpers:::v
v
makeNd (v, 1)
dim (makeNd (v, 1))
dim (makeNd (v, 3))
m <- arrayhelpers:::m
m
makeNd (m, 1)
dim (makeNd (m, 1))
makeNd (m, 0)
dim (makeNd (m, 0))
makeNd (m, 3)
a <- arrayhelpers:::a
a
dim (makeNd (a, 1))
dim (makeNd (a, 0))
makeNd (a, 2)
makeNd (a, -2)
makeNd (a, -4)
makeNd (a, 3);
a <- array (1 : 24, 4 : 3)
a
restoredim (makeNd (a, 0))
x <- makeNd (a, 0)
attr (x, "old")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.