rEcaDataReport: Data report for R-ECA preparation

Description Usage Arguments Value Examples

View source: R/prepRECA.R

Description

Generates overview of samples to inform on sample availability in potential cell definitions. Informs on which columns maybe be used as fixed effect covariates, and how grouping of covariates is best done for random effects.

The covariates in landings define the cells. For each cell the covariates defining the cell is reported, before the total landed weight, along with the number of unique occurances of covariates not in landings (including catchId and sampleId). Lastly the number of fish measurements for Age, Weight and Length is reported.

Usage

1
rEcaDataReport(samples, landings, covariates)

Arguments

samples

data.table() with samples (as in prepRECA), each row corresponding to one sampled fish. Contains columns:

catchId

Column identifying the catch that the sample was taken from. Typically a haul or a landing.

sampleId

Column identifying the sample. If only one sample is taken for each catch. This can be set equal to catchId

Age

integer() Age of fish.

Length

numeric() Length of fish. Must be complete (no NAs)

Weight

numeric() Weight of fish.

...

Additional columns which may be used as covariates.

landings

data.table() with total landings (as in prepRECA), each row corresponding to one cell. Contains columns:

LiveWeightKG

numeric(). Total landings (Live/Round weight in Kg) for the cell

...

Additional columns which may be used as covariates. These will define each cell.

covariates

character() vector of columns to consider for covariates.

Value

data.table() with columns

<Covariates in landings>

one column for each. Defines the cells.

LiveWeightKG

The total weight (kg) in the cell.

LiveWeightCumFraction

The fraction of landings in this cell AND all the cells with higher total weight than this cell.

<Count of covariates not in landings>

Count of unique values for covariate. one column for each. Column name is covariate name (from samples) prefixed with N

Ncatch

The number of unique catches sampled in the cell.

Nsample

The number of unique catch-samples in the cell.

Nage

The number of age readings in the cell.

Nweight

The number of fish weight measurements in the cell.

Nlength

The number of fish length measurements in the cell.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
 samples <- extractBV(prepRECA::NORportsampling2018$BV,
     c("Age", "Length", "Weight"),
     c("integer", "numeric", "numeric"))
 samples <- merge(samples, prepRECA::NORportsampling2018$SA, by="SAid")
 samples <- merge(samples, prepRECA::NORportsampling2018$SS, by="SSid")
 samples <- merge(samples, prepRECA::NORportsampling2018$LE, by="LEid",
     suffixes = c("", ".LE"))
 samples <- merge(samples, prepRECA::NORportsampling2018$VD, by="VDid")
 samples$catchId <- samples$LEid
 samples$sampleId <- samples$SAid
 samples$date <- samples$LEdate
 samples$Metier5 <- samples$LEmetier5
 landings <- prepRECA::CLCodHadNOR
 landings$LiveWeightKG <- landings$OfficialLandingsWeight
 landings$Metier5 <- landings$FishingActivityCategoryEuropeanLvl5
 rEcaDataReport(samples, landings, c("Metier5", "VDencrCode"))

edvinf/prepRECA documentation built on Nov. 11, 2019, 6:30 a.m.