Skip to contents

The function restructures a matrix and extends its current limits to a range defined by a names attribute

Usage

newbounds(x, cols = NULL, rows = NULL)

Arguments

x

The matrix to be restructured.

cols

Column names guiding the restructuring.

rows

Row names guiding the restructuring.

Value

A matrix with extended bounds.

Details

This is essentially a subsetting function that allows you to subset even when the rownames or colnames vector extends beyond the bounds of a matrix and traditional subsetting methods result in the notorious 'out of bounds' error.

Examples

a<-matrix(1:9, ncol=3)
rownames(a) <- c("a", "c", "d")
newbounds(a, rows=letters[1:5])
#>   [,1] [,2] [,3]
#> a    1    4    7
#> b   NA   NA   NA
#> c    2    5    8
#> d    3    6    9
#> e   NA   NA   NA