FrequencyTable {aLBI}R Documentation

Generate a Frequency Distribution Table for Fish Length Data

Description

This function creates a frequency distribution table for fish length data, allowing users to specify or calculate the ideal bin width based on Sturges' formula. The function returns a data frame containing the upper boundary of each length class and its associated frequency.

Arguments

data

A numeric vector or data frame containing fish length measurements. If a data frame is provided, the first numeric column will be selected.

bin_width

(Optional) A numeric value specifying the bin width for class intervals. If not provided, the bin width is automatically calculated using Sturges' (1926) formula.

Details

The ideal bin width is calculated if not provided, based on Sturges' formula:

\text{Bin Width} = \frac{\text{Range}}{\text{Number of Classes}}

where the number of classes is determined as 1 + 3.322 \log_{10}(N) for a dataset of size N.

Value

A data frame with two columns: Upper_Length representing the upper boundary of each length class, and Frequency representing the count of observations within each class.

Examples

# Generate random fish length data
set.seed(123)
fish_lengths <- data.frame(Length = runif(2000, min = 5, max = 70))

# Create a frequency table with an automatically calculated bin width
FrequencyTable(data = fish_lengths$Length)

# Specify a bin width of 5 and generate a frequency table
FrequencyTable(data = fish_lengths$Length, bin_width = 5)
utils::data("ExData", package = "aLBI")


[Package aLBI version 0.1.6 Index]