nonZero: Return the nonzero columns and rows

Description Usage Arguments Examples

Description

Quick function for finding the nonzero columns of a matrix.

Usage

1
nonZero(Z, thresh = 1e-06, zero.col = NULL)

Arguments

Z

A matrix of variables, where some columns or rows are entierly zero.

thresh

A threshold value to round values off at.

zero.col

A vector of columns to take for the removal of the matrix.

Examples

1
2
3
4
a <- matrix(c(rep(0,3),1,0,1,rep(0,3)),3,3)
a
nonZero(a) #removes all rows and columns with nonzero elements
nonZero(a,zero.col = 2) # removes only nonzero rows and columns from row 2.

matt-sutton/sgspls documentation built on June 22, 2019, 10:21 a.m.