getComps | R Documentation |
getComps()
first sets up the local environment, then runs
getcomps_long()
, and finally returns the results of getcomps_long()
,
which calculates summaries by groupings. getcomps_long()
was developed to
make use of tidyverse but it still produces all of the old output. In the
future, this function will be replaced by code that can summarize both
survey data or commercial data. Until then, this is the best we can do and
it mimics old output such that legacy code will not break. You can and
should pass arguments to getcomps_long()
using pass through arguments in
your call to getComps()
, i.e., ...
, especially when calculating
composition data related to age. See the input arguments for more details.
getComps(
Pdata,
strat = NULL,
Comps = c("AAL", "LEN", "AGE"),
defaults = c("fleet", "fishyr", "season"),
verbose = lifecycle::deprecated(),
...
)
getcomps_long(
data,
towstrat,
type,
towid = "SAMPLE_NO",
weightid = "Final_Sample_Size_L",
dropmissing = TRUE
)
Pdata |
A data frame of biological samples
originating from the
Pacific Fishieries Information Network (PacFIN) data warehouse,
which originated in 2014. Data are pulled using sql calls, see
|
strat |
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 |
Comps |
The type of composition data to create. See the function call
for the available options. The first option listed is the default, which
creates conditional age-at-length compositions by adding both |
defaults |
The default stratification columns which will typically be
left at their default value of |
verbose |
Is deprecated as of version 0.2.8. No information is printed to the screen from this function. |
... |
Pass additional arguments to |
data |
A data frame. The data frame must have the column names that
are specified for the next four input arguments, |
towstrat |
A vector of character values providing the column names for which you want compositions for. |
type |
A character value specifying which category to summarize by,
i.e., |
towid |
A vector of character values providing the column names that generate a unique id for each sample. |
weightid |
A character value giving the column name that holds the value to be summed for each type and strata. |
dropmissing |
A logical value supplied to the |
This function uses the expansions created in getExpansion_1()
and
getExpansion_2()
using "weightid"
. Thus, whatever column name is passed
to weightid
will be used as the weight for each group. See the
documentation for the pass-through arguments, i.e., ...
A long data frame of weights for each grouping structure. Columns identifying the grouping structures will come first, followed by columns with sample sizes per group by sex category. The documentation for these sample size columns is sparse because this function is set to be deprecated next cycle and replaced with a simplified path to writing composition data. But, information is present for males (sometimes abbreviated with an m), females (sometimes abbreviated with an f), unsexed (sometimes abbreviated with a u), and sexed (noted as both or b) records. If no sex is provided then it is assumed all are unsexed and will be returned as such.
getcomps_long()
: The actual workhorse behind getComps()
.
Andi Stephens, Kelli F. Johnson
getExpansion_2()
should be run before this function.
writeComps()
can be run on the output from this function.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.