Skip to contents

Deletes or adds whole rows/columns at the edges of A – TDA's mtrim. A positive count deletes that many rows or columns from that edge; a negative count adds that many zero rows/columns instead. leading_cols/trailing_cols act on the first and last columns, leading_rows/ trailing_rows on the first and last rows.

Usage

tda_mtrim(
  A,
  leading_cols = 0,
  leading_rows = 0,
  trailing_cols = 0,
  trailing_rows = 0,
  dir = tempfile("tda")
)

Arguments

A

a numeric matrix.

leading_cols, trailing_cols, leading_rows, trailing_rows

integer counts (default 0); positive deletes, negative pads with zeros.

dir

working directory.

Value

A numeric matrix.

See also

Examples

A <- matrix(1:4, 2)
tda_mtrim(A, leading_cols = 1)    # drop the first column
#>      [,1]
#> [1,]    3
#> [2,]    4
tda_mtrim(A, leading_cols = -1)   # add a zero column in front
#>      [,1] [,2] [,3]
#> [1,]    0    1    3
#> [2,]    0    2    4