View source: R/rank-threshold.R
rank_threshold | R Documentation |
Calculate a threshold value of a vector based on the unimodal threshold method described by Rosin 2001 for image thresholding. Conceptually, the method attempts to draw a line from the peak of the distribution to the tail and calculates the maximum distance from a point to that line. The point where the distance is maximized is the threshold.
rank_threshold(x, show = FALSE)
x |
numeric vector of values. |
show_plot |
logical. default (FALSE). Show the scatter plot for the given distribution. |
The function takes a numeric vector and ranks the values using data.table::frank
.
with ties.method = "first"
. The returned values for the threshold "x" and "y",
indicate the rank of the data point and the value at that rank, respectively.
named vector containing "x" and "y" position of calculated threshold
# simulate exponential counts
x <- (1:100)^exp(3)
rank_threshold(x, show = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.