approx_adjust {beadplexr}R Documentation

Approximate bandwidth adjustment.

Description

Approximates the adjust argument to stats::density() needed to find the required number of clusters.

Usage

approx_adjust(.x, .k, .lower = 0.4, .upper = 2, .step = 0.2)

Arguments

.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.

Details

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.

Value

A numeric.

Examples


set.seed(1234)
.x <- c(rnorm(100, 2, 1), rnorm(100, 9, 1))
approx_adjust(.x, 2)

[Package beadplexr version 0.4.0 Index]