View source: R/turning_points.R
approx_adjust | R Documentation |
Approximates the adjust argument to stats::density()
needed to find the required number of clusters.
approx_adjust(.x, .k, .lower = 0.4, .upper = 2, .step = 0.2)
.x |
A numeric vector. |
.k |
Numeric giving the number of expected clusters. |
.lower, .upper |
The interval for possible value of adjust. |
.step |
A numeric giving the increment to adjust. Sometimes low values are needed to find a proper adjust value. |
This function finds the first value of the stats::density()
adjust
argument which gives the .k
number of clusters. It it quite crude in that
every value of adjust from .lower
to .upper
is tested until the desired
number of clusters is found. A cluster is defined by a peak, and should no
suitable adjust
value be found, NA is returned.
A numeric.
set.seed(1234)
.x <- c(rnorm(100, 2, 1), rnorm(100, 9, 1))
approx_adjust(.x, 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.