Calculate more detailed density of numeric values

breakDensity(
  x,
  breaks = length(x)/3,
  bw = NULL,
  width = NULL,
  densityBreaksFactor = 3,
  weightFactor = 1,
  addZeroEnds = TRUE,
  baseline = 0,
  floorBaseline = FALSE,
  verbose = FALSE,
  ...
)

Arguments

x

numeric vector

breaks

numeric breaks as described for stats::density() except that single integer value is multiplied by densityBreaksFactor.

bw

character name of a bandwidth function, or NULL.

width

NULL or numeric value indicating the width of breaks to apply.

densityBreaksFactor

numeric factor to adjust the width of density breaks, where higher values result in less detail.

weightFactor

optional vector of weights length(x) to apply to the density calculation.

addZeroEnds

logical indicating whether the start and end value should always be zero, which can be helpful for creating a polygon.

baseline

optional numeric value indicating the expected baseline, which is typically zero, but can be set to a higher value to indicate a "noise floor".

floorBaseline

logical indicating whether to apply a noise floor to the output data.

verbose

logical indicating whether to print verbose output.

...

additional parameters are sent to stats::density().

Details

This function is a drop-in replacement for stats::density(), simply to provide a quick alternative that defaults to a higher level of detail. Detail can be adjusted using densityBreaksFactor, where higher values will use a wider step size, thus lowering the detail in the output.