writeComps: Write out composition data formatted for Stock Synthesis.

Description Usage Arguments Details Author(s) See Also

View source: R/writeComps.R


Write out composition data to a file, binning the data as specified.


PacFIN data should first be stratified using getComps, then sexes should be assigned as males and females by doSexRatio before using writeComps.

Failure to use doSexRatio will result in all unsexed fish being discarded.


writeComps(inComps, fname = "out.csv", abins = NULL, lbins = NULL,
  maxAge = Inf, partition = 0, ageErr = 0, returns = "FthenM",
  dummybins = FALSE, verbose = TRUE)



A dataframe generated as described in Workflow, above.


A filename, used to save the output as a .csv file. Users can specify a full path if they do not want the file written in the current working directory.


Bins to use for ages. Default is the data bins.


Bins to use for lengths. Default is the data bins.


A numeric value specifying the maximum age of fish that should be included in the composition data, unless dummybins = TRUE, then those fish will be included in a plus group which you can investigate later. Note that maxAge is only used if abins = NULL, otherwise fish are binned according to user specified bins irregardless of maxAge.


Defaults to 1.


Defaults to 1.


One of ("FthenM", "Fout", "Mout", or "Uout"). Choose return value of the function. Default: FthenM


A logcial value specifying whether data outside of the lower and upper abins or lbins should be added to dummy bins, or be placed in the specified bins. Default is TRUE. Dummy bins are useful for determining whether the current bin structure properly captures the data.


A logical value specifying if output should be written to the screen or not. Good for testing and exploring your data but can be turned off when output indicates errors. The default value is TRUE.


The structure of the input dataframe determines whether writeComps produces age-, length-, or conditional-age-at-length- composition data.

Four sets of composition data are written to a single file specified by fname. These are:

The output file is appended to, rather than overwritten, so you may want to specify a new filename each time you generate a different stratification or bin structure, e.g., "out.1.csv", "out.2.csv".

Composition data are raw weights rather than proportions. Stock Synthesis internally converts these to proportions. The raw weights should be examined for anomalies.

To create proportions use prop.table on the columns containing composition data.

The columns in the output preceeding 'lengthcm' or 'age' are those that were used in stratifying the data.

Reality Checks

#' @return Appends data to the file given in fname.

Conditionally returns a dataframe if the out argument specifies the type of composition to return.


Andi Stephens

See Also

getComps, doSexRatio

nwfsc-assess/PacFIN.Utilities documentation built on June 30, 2017, 8:49 a.m.