bind_as_*
introduces a new dimension, such that each element in
list_of_arrays
corresponds to one index position along the new dimension in
the returned array. bind_on_*
binds all elements along an existing
dimension, (meaning, the returned array has the same number of dimensions as
each of the arrays in the list).
bind_as_dim(list_of_arrays, which_dim) bind_as_rows(...) bind_as_cols(...) bind_on_dim(list_of_arrays, which_dim) bind_on_rows(...) bind_on_cols(...)
list_of_arrays | a list of arrays. All arrays must be of the same dimension. NULL's in place of arrays are automatically dropped. |
---|---|
which_dim | Scalar integer specifying the index position of where to
introduce the new dimension to introduce. Negative numbers count from the
back. For example, given a 3 dimensional array, |
... | Arrays to be bound, specified individually or supplied as a single list |
An array, with one additional dimension.
bind_*_rows()
is a wrapper for the common case of bind_*_dim(X, 1)
.
bind_*_cols()
is a wrapper for the common case of bind_*_dim(X, -1)
.
#> [1] 2 3 4#> [1] 10 2 3 4#> [1] TRUE# each element in `list_of_arrays` corresponds to one "row" # (i.e., one entry in along the first dimension) for(i in seq_along(list_of_arrays)) stopifnot(identical(combined_as[i,,,], list_of_arrays[[i]])) # bind on an existing dimension combined_on <- bind_on_rows(list_of_arrays) dim(combined_on)#> [1] 20 3 4#> [1] TRUE#> [1] TRUEfor (i in seq_along(list_of_arrays)) stopifnot(identical( list_of_arrays[[i]], combined_on[ (1:2) + (i-1)*2,,] )) # bind on any dimension combined <- bind_as_dim(list_of_arrays, 3) dim(combined)#> [1] 2 3 10 4