formatCatch.Rd
Transform a long data frame of catches to a wide data frame using tidyr::pivot_wider. The column names of the wide data frame will be in the format needed for the stratification of stage-2 expansions of composition data, i.e., getExpansion_2.
formatCatch(
catch,
strat,
yearname = "^Year|^Yr|Landing_Y|Sample_Y",
valuename = "ROUND_WEIGHT_LBS"
)
A data frame with at least a column specifying the year the catches took place (e.g., LANDING_YEAR is the column name upon download from PacFIN), a column for variable(s) specified in strat, and a column that holds the measured catches named (e.g., ROUND_WEIGHT_LBS is the column name upon download from PacFIN).
A vector of column names to stratify the output over. For
example, if you wish to summarize by ageing method, then the argument
would look like strat = "agemethod"
or, if you want to look at fleets
and gear, strat = c("fleet", "usegear")
.
A character string used to search for year in catch
.
Ensure that the string is unique enough that it will only return one value.
Though, if you would like catch by year and month you can pass a single
character value that includes both of these, for example _YEAR|_MONTH
.
This is underhanded and not what the original functionality of this function
intended, but feel free to use it.
This is not case specific.
The column name that contains the
catch values in the data frame ROUND_WEIGHT_LBS
is the default and the
name of the column that contains landed weight converted to round weight
in lbs. The conversion factor from landed weight to round weight is
weight_of_catch * NVL(conversion_factor,1) and 1 mt equals 2,204.62 lbs.
This is not case specific.
A data frame in wide format with yearname
being the first column
ordered from oldest to newest. Stratification columns follow and the names
are separated with a full stop when more than one stratification is provided.
Values in the rows will be the valuename
summed across all available values.
If there are no relevant values for a given stratification-year combination,
then the entry will be zero.