Description Usage Arguments Details Value
View source: R/append.dimensions.R
Given an array (that must have dimension-names since the code
depends on abind::afill
), a named list with new
dimension-names, and a vector of positions for these new dimensions
in the resulting array - then this function can create an extended
version of the original array by stacking the content of it into
the new one.
1 | append_dimensions(orig_arr, added_dimnames, positions)
|
orig_arr |
The original array that we want to "stack" several copies of into an enlarged array. |
added_dimnames |
A list that specifies the dimension-names that we want to append. Note that this list must be named in order for the code to work. |
positions |
A vector the positions that we want the new
dimensions to occur at. The default is to append the extra
dimensions after those of |
This might come in handy e.g. when a for-loop can be avoided in favour of an operation of arrays instead, but where we need to add some extra stuff to our original array in order to ensure the operation is well-defined.
If the arrays are very large, it might in addition be preferable to use the recycle-smallest-vector feature of R when we do our operation, since that in many cases will enable us to only have one humongous array instead of two. However, for this to work it is necessary to control exactly where the extra dimensions are positioned - which can be a rather frustrating task to undertake. This function will in those cases take care of most of the pesky details for us.
An enlarged array, where the original array is stacked (by
the help of abind::afill<-
).
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.