matrix_threshold: Remove values from Matrix based on threshold

Description Usage Arguments Details Value Author(s) Examples

View source: R/matrix_threshold.R

Description

Returns matrix with values above or below the threshold are replaced. Can be used for converting to a binary matrix or for thresholding an adjacency matrix.

Usage

1
matrix_threshold(matrix, threshold=NULL, minval=0, maxval=NULL, abs=TRUE, rmna=FALSE,...)

Arguments

matrix

matrix

threshold

Integer

minval

Integer. Replaces values below threshold.

maxval

Integer. Replaces values above or equal to threshold.

abs

Logical. If TRUE the absolute value will be considered.

rmna

Logical. If TRUE NA's will be replaced with minval.

...

Other parameters.

Details

If rm.na is TRUE and minval is NULL, then NA's will be replaced with 0.

Value

max_threshold returns an matrix with values removed according to parameters.

Author(s)

Shannon M. Bell

Examples

1
2
3
4
5
 #using USArrest dataset
 arrestCor<-cor(t(USArrests))
 arrestCor.7<-matrix_threshold(arrestCor, threshold=0.7, minval=0, abs=TRUE, rm.na=FALSE)
 arrestCor[10:15,1:5]
 arrestCor.7[10:15,1:5]

Example output

           Alabama    Alaska   Arizona  Arkansas California
Georgia  0.9998347 0.9897012 0.9992693 0.9998995  0.9955203
Hawaii   0.0000000 0.0000000 0.0000000 0.0000000  0.0000000
Idaho    0.9711302 0.9447686 0.9802287 0.9761620  0.9881726
Illinois 0.9946122 0.9772742 0.9975498 0.9964785  0.9981170
Indiana  0.9379024 0.9041874 0.9518965 0.9454442  0.9657722
Iowa     0.7057595 0.0000000 0.7336002 0.7203431  0.7656561
           Alabama    Alaska   Arizona  Arkansas California
Georgia  0.9998347 0.9897012 0.9992693 0.9998995  0.9955203
Hawaii   0.0000000 0.0000000 0.0000000 0.0000000  0.0000000
Idaho    0.9711302 0.9447686 0.9802287 0.9761620  0.9881726
Illinois 0.9946122 0.9772742 0.9975498 0.9964785  0.9981170
Indiana  0.9379024 0.9041874 0.9518965 0.9454442  0.9657722
Iowa     0.7057595 0.0000000 0.7336002 0.7203431  0.7656561

NetComp documentation built on May 2, 2019, 8:15 a.m.