Expand Length Frequency Data for a Single Species Row
expand_length_frequency.RdTakes a single species row and expands it into multiple rows if length frequency data is present. Preserves all metadata (counting_method, species, etc.) throughout.
Value
A data frame with one or more rows:
If length frequency data exists: multiple rows (one per length bin)
If no length frequency data: single row with NA for length fields
Details
This function processes length frequency data in a row-by-row manner, which is simpler and more robust than extracting all length data first and then joining.
The function:
Identifies length group columns in the row
If found: pivots them to create multiple rows (one per length bin)
If not found: returns the row as-is with NA length fields
Always preserves all metadata columns