View source: R/FrequencyTable.R
FrequencyTable | R Documentation |
This function creates a frequency distribution table for fish length data, using either a custom bin width or Wang's formula to calculate the ideal bin width. If the calculated bin width is a fraction, it is rounded to the nearest integer.
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 Wang's formula. |
Lmax |
(Optional) The maximum observed length of fish. Required only if the maximum length is not provided and bin width is calculated using Wang's formula. |
A list containing two data frames:
lfqTable |
A frequency table with the length range and frequency. |
lfreq |
A table with the upper limits of bins and their frequencies. |
# Generate random fish length data
set.seed(123)
fish_lengths <- data.frame(Length = runif(2000, min = 5, max = 70))
# Create a frequency table using Wang's formula (default)
FrequencyTable(data = fish_lengths$Length)
# Create a frequency table with a custom bin width
FrequencyTable(data = fish_lengths$Length, bin_width = 5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.