matrixtrim: Trim Matrix

Description Usage Arguments Value Examples

View source: R/matrixtrim.R

Description

Trim the rows and columns of a logical matrix until every row and columns has a specified level of TRUE values.

Usage

1
matrixtrim(m, prop = c(1, 1), rowsfirst = TRUE)

Arguments

m

A logical matrix to be trimmed, should be all TRUE, FALSE (or 0, 1).

prop

A numeric vector of length two, the minimum proportion of TRUE values in each row and column of the trimmed matrix, default c(1, 1).

rowsfirst

A logical scalar, indicating if rows (TRUE, the default) or columns (FALSE) should be trimmed from the matrix first.

Value

A list of length three:

Examples

1
2
3
4
m <- matrix(rep(c(1, 0, 1, 0), c(4, 1, 13, 2)), nrow=5)
matrixtrim(m)
matrixtrim(m, rowsfirst=FALSE)
matrixtrim(m, prop=c(0.7, 0.7))

JVAdams/jvamisc documentation built on Aug. 11, 2021, 6:43 a.m.