Learn R Programming

usefun (version 0.4.5)

binarize_to_thres: Binarize matrix to given threshold

Description

Simple function that checks every element of a given matrix (or data.frame) if it surpasses the given threshold either positively or negatively and it outputs 1 for that element, otherwise 0.

Usage

binarize_to_thres(mat, thres)

Arguments

mat

a matrix or data.frame object

thres

a positive numerical value

Value

a binarized matrix (values either 0 or 1): elements that have 1 correspond to values of mat that they were either larger than the threshold or smaller than it's negative.

Examples

Run this code
# NOT RUN {
mat = matrix(data = -4:4, nrow = 3, ncol = 3)
binarize_to_thres(mat, thres = 0.5)
binarize_to_thres(mat, thres = 2.5)

# }

Run the code above in your browser using DataLab