cleanPacFIN: Filter PacFIN samples.

Description Usage Arguments Details Value Author(s) See Also

View source: R/cleanPacFIN.R

Description

cleanPacFIN filters out unsuitable samples from data, and converts fish lengths to cm. The original fields in the returned data are left untouched, with the exception of SEX, which is modified so that unidentified fish are labeled "U".

Workflow

If there are CalCOM samples to be integrated with PacFIN data, run combineCalCOM first, otherwise run to cleanPacFIN as the first function in the workflow.

Usage

1
2
3
4
cleanPacFIN(Pdata, only_USINPFC = FALSE, keep_INPFC = NULL,
  remove_INPFC = NULL, badRecords = NULL, keep_sample_type = c("", "M"),
  keep_sample_method = "R", keep_missing_lengths = FALSE, keep_CA = TRUE,
  CLEAN = TRUE)

Arguments

Pdata

a PacFIN dataset

only_USINPFC

a logical value. FALSE by default.

keep_INPFC

a set of INPFC areas. NULL by default.

remove_INPFC

a set of INPFC areas. NULL by default.

badRecords

a set of sample identifiers. NULL by default.

keep_sample_type

a set of sample types to retain. Default = c("", "M")

keep_sample_method

a set of sample methods to retain. Default = "R"

keep_missing_lengths

a logical value. FALSE by default.

keep_CA

default TRUE. CA data often have no sample type or method, or INPFC area.

CLEAN

a logical value. Default is TRUE. If FALSE, return the original data unchanged, but report what would have been removed.

Details

INPFC Area specification

The US INPFC areas are c("VUS","CL","VN","COL","NC","SC","EU","CALCOM","CP","EK","MT","PS ")

"CalCOM" is included because the combineCalCOM function sets it, since CalCOM doesn't seem to record INPFC areas.

If only_USINPFC is TRUE, then only samples from the US INPFC areas will be retained.

If a set of INPFC areas are specified in keep_INPFC, then only samples from those areas will be retained.

If remove_INPFC specifies a set of INPFC areas, samples from those areas will be discarded.

Sample types and methods

SAMPLE_TYPEs may be (M=Market, R=Research, S=Special request, C=Commercial on-board). Only samples of type M are generally used.

SAMPLE_METHODs may be (R=Random, S=Stratified, N=Systematic, P=Purposive, X=Special). Only samples collected in random sampling are generally used.

Furthermore

The values created as new columns are for use by other functions in this package. In particular, fishyr and season are useful if there are multiple seasons (e.g., winter and summer, as in the petrale sole assessment), and the year is adjusted so that "winter" occurs in one year, rather than across two.

The fleet, fishery, and state columns are meant for use in stratifying the data according to the particulars of an assessment.

The sink command can be used to save the filtering report to a file, in addition to printing it to the console.

Value

The input data filtered for desired areas and record types specified, with added columns

fishyr initialized from SAMPLE_YEAR
fleet initialized to 1
fishery initialized to 1
season initialized to 1. Change using getSeason
state initialized from SOURCE_AGID. Change using getState
lengthcm floored cm from FORK_LENGTH when available, otherwise FISH_LENGTH
geargroup the gear group associated with each GRID, from http://pacfin.psmfs.org/pacfin_pub/data_rpts_pub/code_lists/gr.txt

Author(s)

Andi Stephens

See Also

cleanAges, getState, getSeason, sink


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