binarize_to_thres | R Documentation |
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.
binarize_to_thres(mat, thres)
mat |
a matrix or data.frame object |
thres |
a positive numerical 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.
mat = matrix(data = -4:4, nrow = 3, ncol = 3)
binarize_to_thres(mat, thres = 0.5)
binarize_to_thres(mat, thres = 2.5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.