log2bins: Construct bins that double in size and encompass the data,

View source: R/fitting.R

log2binsR Documentation

Construct bins that double in size and encompass the data,

Description

Construct bins that double in size and encompass the data, resulting in binBreaks ..., 0.25, 0.5, 1, 2, 4, 8, 16,.... as necessary, where the breaks are powers of 2. Adapting from LBNbiom.method(). See binData() for a generalised version.

Usage

log2bins(x = NULL, counts = NULL)

Arguments

x

vector of individual values (e.g. body masses)

counts

dataframe (or array) with first column being an x value (e.g. body mass), and second column being the counts of the number of individuals for that value. Only x or counts can be specified.

Value

  list containing:
  • indiv: dataframe with a row for each x value, with columns:

    • x: original x values

    • binMid, binMin, binMax, binWidth: midpoint, minimum, maximum, and width, respectively, of the bin within which the x value falls. If indiv has >=10^6 rows then it isn't saved. If counts was specified then an equivalent x vector is created and is column x (i.e. x values are repeated). May not be the most efficient way, but it easiest to program. May not need indiv returned, but it needs to be calculated anyway.

  • binVals: dataframe with a row for each new bin, with columns:

    • binMid, binMin, binMax, binWidth: midpoint, minimum, maximum, and width, respectively, of the bin

    • binCount: total number of individuals in that bin

    • binCountNorm: binCount / binWidth

    • binSum: sum of individual values in that bin (appropriate if x represents biomass, but not length)

    • binSumNorm: binSum / binWidth

    • log10...: log10() of some of the above quantities.

Author(s)

Andrew Edwards


andrew-edwards/sizeSpectra documentation built on June 28, 2023, 7:09 p.m.