Resets the dimension of a spam matrix by truncation or zero padding.

pad(x) <- value
<!-- %"pad&lt;-.spam"(x,value) -->

Arguments

x

a spam matrix

value

A numeric two-vector.

Value

A (spam) matrix of dimension value where trunction or padding has been used.

Details

It is important to notice the different behavior of the replacement method for ordinary arrays and spam objects (see ‘Examples’). Here, the elements are not simply rearranged but an entirely new matrix is constructed. If the new column dimension is smaller than the original, the matrix is also cleaned (with option("spam.eps") as filter).

See also

Author

Reinhard Furrer

Examples

x <- diag(4)
dim(x)<-c(2,8)
x
#>      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
#> [1,]    1    0    0    0    0    1    0    0
#> [2,]    0    0    1    0    0    0    0    1

s <- diag.spam(4)
pad(s) <- c(7,3)  # any positive value can be used

s <- diag.spam(4)
pad(s) <- c(2,8)  # result is different than x