add_missing_zeros: Add missing zeros to data frame of catch rates

View source: R/add_missing_zeros.R

add_missing_zerosR Documentation

Add missing zeros to data frame of catch rates

Description

add_missing_zeros takes a compressed ‘long-form' data frame, and adds rows for samples that were conducted but didn’t catch any of a given fish species

Usage

add_missing_zeros(data_frame, unique_sample_ID_colname, sample_colname,
  species_colname, species_subset = NULL, Method = "Slow",
  if_multiple_records = "Error", verbose = TRUE, save_name = NULL,
  error_tol = 1e-12)

Arguments

data_frame

data frame containing data that missing zeros

unique_sample_ID_colname

column name from 'data_frame' that gives a unique ID for each sample (where rows with the same unique ID are different species from the same sample)

sample_colname

column name from 'data_frame' for sample of each species (e.g., representing catch in weight)

species_colname

column name from 'data_frame' identifying species sampled for each row

species_subset

character vector giving levels of 'species_colname' that should be retained (representing which species to keep); if NULL, then species_subset=levels(data_frame[,'species_colname'])

Method

whether to use fast or slow method (fast may be more robust, and has more options for multiple_records)

if_multiple_records

What to do if multiple rows have the same vales for data_frame[,'unique_sample_ID_colname'] and data_frame[,'species_colname']

verbose

Boolean, whether to print output to screen

save_name

optional directory for saving result locally

error_tol

value used in checking that final biomass matches original biomass (if error_tol=Inf then no error checking is done)

Value

A data frame with number of rows equal to number of unique samples times number of species


James-Thorson/FishData documentation built on March 21, 2023, 3:54 a.m.