writeComps.Rd
Write out composition data to a file, binning the data as specified to work in a Stock Synthesis model. Note, that this function does not work for conditional age-at-length data because it is assumed that one would not want to estimate growth in that way from fishery-dependent data.
writeComps(
inComps,
fname = NULL,
abins = lifecycle::deprecated(),
lbins = lifecycle::deprecated(),
comp_bins = NULL,
column_with_input_n = "n_tows",
maxAge = lifecycle::deprecated(),
month = 7,
partition = 2,
ageErr = 0,
dummybins = lifecycle::deprecated(),
sum1 = lifecycle::deprecated(),
digits = 4,
overwrite = lifecycle::deprecated(),
verbose = FALSE
)
A dataframe returned from getComps()
.
A filename with the appropriate extension, used to save the
function output to the disk. For example, LenComps.csv
or
file.path(getwd(), "SampleSize.csv")
. Full, relative, or simple paths are
allowed because the argument is used as is, i.e., not redirected to a
directory different than getwd()
. Note that various functions within
pacfintools have different default values for this input argument. If
NULL
in writeComps
, then the resulting file name will be based on what
type of composition data is being generated, i.e., PacFIN_lengths.out
,
or PacFIN_ages.out
for length or age data, respectively.
Deprecated as of 0.2.10 to reduce complication in the code and
make it more intuitive for the user when running this function.
The binning structure to use for ages and lengths. For
both arguments, the default is NULL
which leads to the natural bins of
the data being used, i.e., no additional binning is performed.
The binning structure to use for ages and lengths. The default
is NULL
which leads to the natural bins of the data being used, i.e.,
no additional binning is performed.
A string providing the column name with the
appropriate value for the input sample size that will be given to Stock
Synthesis as input_n (what we and nwfscSurvey provide as a column name)
or NSamp (what Stock Synthesis wants as a name). The default is "n_tows"
,
which is the number of tows that were performed for the given
stratifications passed to getComps()
that created inComps
. One might
want to use "n_fish"
or some column that you created yourself.
Deprecated as of 0.2.10 to reduce complication in the code and
make it more intuitive for the user when running this function. All fish
present in inComps
will be binned according to the bins provided or the
bins present.
Month for all observations. Defaults to 7. If input has multiple seasons, this must be a vector of equal length to the maximum seasons where the order of months in the vector will be assigned to season in ascending order. For example, if there are two seasons and the month = c(1, 7) season 1 will be assigned to month 1 and season 2 to month 7.
Used by Stock Synthesis for length- or age-composition data where 0 = retained + discarded, 1 = discarded, and 2 = retained fish. The default is to assume that these fish are retained only. The default was changed in 2020 from a value of 0, and code should be updated accordingly if you really want 0.
Defaults to 1 to use the first ageing error matrix specified in your Stock Synthesis model.
Deprecated as of version 0.2.10 because you can just run the
function with different abins
or lbins
rather than this function
changing the first and end bin for you. The original default, years ago was
TRUE
, then it was changed to FALSE
. Now, without this argument, it is
essentially FALSE
.
Deprecated as of version 0.2.10 because SS3 will normalize the
composition data for you and thus it does not need to be done here. The
previous default was FALSE
so the removal of this argument does not
change the default behavior of this function.
Integer indicating the number of decimal places to round value
to (value is passed to round()
). The default is 4, which will lead to
rounding to four digits. If you do not want to round the results, then use
Inf
, which will lead to the use of R's default precision.
Deprecated as of version 0.2.10. The file will be automatically overwritten if present.
A logical 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 information that you already know. The printing
of output to the screen does not affect any of the returned objects. The
default is to always print to the screen, i.e., verbose = TRUE
.
A data frame is returned and a .csv
is created and written to the disk with
the same data frame.
The structure of the input dataframe determines whether the results produce age- or length-composition data. As of version 0.2.10, conditional age-at-length compositions are no longer available within this function.
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 preceding 'lengthcm' or 'Age' are those that were used in stratifying the data.