comp_complete: Complete each data frame in a list of comp data frames so...

View source: R/comp_complete.r

comp_completeR Documentation

Complete each data frame in a list of comp data frames so that all have the same dimensions

Description

Complete each data frame in a list of comp data frames so that all have the same dimensions

Usage

comp_complete(
  comp_list,
  comp_data_n,
  xbin_by_df = FALSE,
  n_tag = c(".n", ".nfish"),
  n_colname_new = c("ntrip", "nfish"),
  rownames_num = NULL,
  colnames_num = NULL,
  output_type = "prop",
  minus_group = FALSE,
  plus_group = FALSE,
  valsToNA = -99999
)

Arguments

comp_list

list of composition matrices, where column names are bin values (e.g. length or age), and rows are unique observations (e.g. years)

comp_data_n

data frame with annual sample sizes associated with each comp matrix

xbin_by_df

If true, x values are determined separately for each data frame (e.g. length comps may be binned separately by fleet)

n_tag

tag(s) added to end of columns in comp_data_n which indicate sample sizes (e.g. ".n", ".nfish")

n_colname_new

column name values to associate with n_tag in output

rownames_num

Names of data rows for each comp matrix (e.g. years) desired in output.

colnames_num

Names of data columns for each comp matrix (e.g. age bins, length bins) desired in output.

output_type

Type of comps to output: "input"= format used in spreadsheets when submitting data, including ntrip and and nfish columns, "prop" = matrix of proportions, "nfish" = matrix of numbers of fish

minus_group

logical. Should a minus group be computed? If TRUE, data for groups <=min(colnames_num) will be summed into min(colnames_num). If FALSE data <min(colnames_num) will simply be truncated.

plus_group

logical. Should a plus group be computed? If TRUE, data for groups >=max(colnames_num) will be summed into max(colnames_num). If FALSE data >max(colnames_num) will simply be truncated.

valsToNA

Values that should be replaced with NA (e.g. -99999)

Author(s)

Nikolai Klibansky

Examples

## Not run: 
# Combine age comp matrices for Red Porgy
cm <- rdat_RedPorgy$comp.mats
cma <- cm[grepl("^acomp.*ob$",names(cm))]

cman <- rdat_RedPorgy$t.series[,gsub("ob$","n",names(cma))]
cmanfish <- rdat_RedPorgy$t.series[,gsub("ob$","nfish",names(cma))]

# Output proportions at age
comp_complete(cma,output_type="prop")

# Output numbers of fish at age
names(cma) <- gsub(".ob$","",names(cma))
comp_complete(cma,cmanfish,output_type="nfish",n_tag=".nfish")

# Output age comps in data input format
comp_complete(cma,cbind(cman,cmanfish),output_type="input")

## End(Not run)


nikolaifish/bamExtras documentation built on July 21, 2023, 8:26 a.m.