Learn R Programming

mmand (version 1.6.3)

threshold: Threshold a numeric array or vector

Description

This function thresholds an array or vector, setting elements below the threshold value to zero. The threshold can be given literally or calculated using k-means clustering.

Usage

threshold(x, level, method = c("literal", "kmeans"), binarise = TRUE)

Arguments

x

A numeric vector or array.

level

The literal threshold level, if required.

method

The method to use to calculate the threshold. If "literal" (the default) then the value of level will be used. If "kmeans" then the threshold value will be determined implicitly using k-means clustering.

binarise

Whether to set suprathreshold elements to unity (if TRUE), or leave them at their original values (if FALSE).

Author

Jon Clayden <code@clayden.org>

See Also

binarise

Examples

Run this code
x <- c(0.1, 0.05, 0.95, 0.85, 0.15, 0.9)
threshold(x, method="kmeans")
threshold(x, 0.5)

Run the code above in your browser using DataLab