binarize_to_thres: Binarize matrix to given threshold

View source: R/operations.R

binarize_to_thresR Documentation

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


mat = matrix(data = -4:4, nrow = 3, ncol = 3)
binarize_to_thres(mat, thres = 0.5)
binarize_to_thres(mat, thres = 2.5)


usefun documentation built on Sept. 15, 2024, 1:06 a.m.