Learn R Programming

slam (version 0.1-54)

abind: Combine Sparse Arrays

Description

Combine a sequence of (sparse) arrays, matrices, or vectors into a single sparse array of the same or higher dimension.

Usage

abind_simple_sparse_array(..., MARGIN = 1L)
extend_simple_sparse_array(x, MARGIN = 0L)

Value

An object of class simple_sparse_array where the dimnames

are taken from the elements of ‘...’.

Arguments

...

R objects of (or coercible to) class simple_sparse_array.

MARGIN

The dimension along which to bind the arrays.

x

An object of class simple_sparse_array.

Author

Christian Buchta

Details

abind_simple_sparse_array automatically extends the dimensions of the elements of ‘...’ before it combines them along the dimension specified in MARGIN. If a negative value is specified first all elements are extended left of the target dimension.

extend_simple_sparse_array inserts one (or more) one-level dimension(s) into x to the right of the position(s) specified in MARGIN, or to the left if specified in negative terms. Note that the target positions must all be in the range of the dimensions of x (see Examples).

See Also

simple_sparse_array for sparse arrays.

Examples

Run this code
## automatic
abind_simple_sparse_array(1:3, array(4:6, c(1,3)))
abind_simple_sparse_array(1:3, array(4:6, c(3,1)), MARGIN = 2L)

## manual
abind_simple_sparse_array(1:3, 4:6)
abind_simple_sparse_array(1:3, 4:6, MARGIN = -2L)   ## by columns
abind_simple_sparse_array(1:3, 4:6, MARGIN = -1L)   ## by rows

##
a <- as.simple_sparse_array(1:3)
a
extend_simple_sparse_array(a, c( 0L, 1L))
extend_simple_sparse_array(a, c(-1L,-2L))   ## the same
extend_simple_sparse_array(a, c( 1L, 1L))

Run the code above in your browser using DataLab