Learn R Programming

NetComp (version 1.6)

matrix_threshold: Remove values from Matrix based on threshold

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

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.

Value

max_threshold returns an matrix with values removed according to parameters.

Details

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

Examples

Run this code
 #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]

Run the code above in your browser using DataLab