expandNA: Expand arrays with missing values and subset arrays

Description Usage Arguments Details Value Examples

Description

This function expands a multi-dimensional array to the dimensionality indicated by filling in missing values. No new dimensions are created but existing dimensions are enlarged. The algorithm is considerably faster if only the last dimension is changed.

Usage

1
2
3
expandNA(x, dims)

shrink(x, dims)

Arguments

x

array with input data

dims

vector with dimensions describing the array extent (dimension i of output ranges from 1:dims[i])

Details

Expansion is performed such that the original data in x sits in the lower left corner of the array (i.e. for each dimension the indices 1:dim(x)). Correspondingly, shrinking is performed by selected the lower-left corner as a subset.

Value

Output array of dimension dims

Examples

1
2
3
tt <- outer(1:4, 1:3, paste, sep=',')
expandNA(tt, c(5,5))
shrink(tt, c(2,2))

jonasbhend/myhelpers documentation built on May 19, 2019, 7:27 p.m.