Description Usage Arguments Details Value Examples

By default, the `matsbyname`

package expends matrices
with `0`

rows or columns prior to matrix operations
to ensure that rows and columns match.
There are times when trimming rows or columns is preferred
over the default behavior.
This function trims rows or columns in `a`

to match
the rows or columns of `mat`

.
The return value will have rows or columns of `a`

removed if they do not appear in `mat`

.

1 | ```
trim_rows_cols(a = NULL, mat = NULL, margin = c(1, 2))
``` |

`a` |
A matrix to be trimmed. |

`mat` |
The matrix |

`margin` |
The dimension of |

If `a`

is `NULL`

, `NULL`

is returned.
If `mat`

is `NULL`

, `a`

is returned unmodified.
If `mat`

has `NULL`

dimnames, `a`

is returned unmodified.
If `mat`

has `NULL`

for dimnames on `margin`

, an error is returned.

Matrix `a`

with rows or columns trimmed to match `mat`

.

1 2 3 4 5 6 7 8 9 10 11 12 | ```
a <- matrix(c(1, 2, 3,
4, 5, 6,
7, 8, 9), nrow = 3, ncol = 3, byrow = TRUE,
dimnames = list(c("r1", "r2", "r3"), c("c1", "c2", "c3"))) %>%
setrowtype("rowtype") %>% setcoltype("coltype")
mat <- matrix(c(1, 2, 3,
4, 5, 6), nrow = 2, ncol = 3, byrow = TRUE,
dimnames = list(c("r1", "bogus"), c("c1", "bogus", "c2"))) %>%
setrowtype("rowtype") %>% setcoltype("coltype")
trim_rows_cols(a, mat, margin = 1)
trim_rows_cols(a, mat, margin = 2)
trim_rows_cols(a, mat)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.