Provides some standard flat tables for analysing NMDbiotic v 3.x data.
PrepareNmdBioticTable(
BioticData,
TargetTable = c("Mission", "FishStation", "CatchSample", "Individual", "Prey",
"MultipleTags", "MultipleReadings", "PreyLengthFrequencies",
"PreyDevstageFrequencies"),
addIds = FALSE
)
A list of list of data.tables corresponding to the different levels of NMD-biotic as read for instance by ReadBiotic
.
character with the name of the lowest table in the hierarchy to include.
logical indicating whether to add convenient ids for the levels in NMDbiotic.
a data.table
with columns as specified in the details section.
NMDbiotic is a hierarchical data format with extendible reference lists, which is represented as a set of linked tables when red with ReadBiotic
.
This function provides some standard merges and concatenations of these tables in order to provide simpler views of the data that fits standard tools for analysis and plotting in R.
A detailed description of the format can be found at https://www.imr.no/formats/nmdbiotic/v3/. Note that this is not the same as the StoxBiotic-format.
Different tables are prepared as specified by the argument 'TargetTable':
The table 'mission'
The table 'fishstaion', merged with 'mission'
The table 'catcsample', merged with 'fishstaton' and 'mission'
The table 'individual', merged with 'catchsample', 'fishstaton', 'mission', 'agedetermination' and 'tag'. Only the preferred age reading for each individual is kept from the table 'agedetermination' (see the field 'preferredagereading'). If an individual has multiple tags, a warning issued and no tags are added to the table for that individual.
The table 'prey', merged with individual', 'catchsample', 'fishstaton', 'mission' and 'agedetermination'. Only the preferred age reading for each individual is kept from the table 'agedetermination' (see the field 'preferredagereading')
The table 'tag', merged with individual', 'catchsample', 'fishstaton', and 'mission.'
The table 'agedetermination', merged with 'individual', 'catchsample', 'fishstaton' and 'mission'
The table 'preylengthfrequencytable', merged with 'prey', 'individual', 'catchsample', 'fishstaton', 'mission' and 'agedetermination'. Only the preferred age reading for each individual is kept from the table 'agedetermination' (see the field 'preferredagereading')
The table 'copepodedevstagefrequencytable', merged with 'prey', 'individual', 'catchsample', 'fishstaton', 'mission' and 'agedetermination'. Only the preferred age reading for each individual is kept from the table 'agedetermination' (see the field 'preferredagereading')
Table names above refer to fields in the detailed description of the nmdbiotic format (https://www.imr.no/formats/nmdbiotic/v3/).
Note that not all tables have corresponding registrations in lower tables. For instance a fishstation does not have to have any records on the individual-table. Preparing e.g. the table 'Individual' will discard any stations or catches that does not contain records for in the individual-table.
If several age reading records are present for an individual, and the preferred age reading is not indicated in the data, the function will halt with an error.
The different levels in NMDbiotic are addressable by a combination of fields. The id for an individual for instance, is only guaranteed to be unique within the sample (catchsample) it belongs to.
Often it is convenient to construct identifiers that are unqiue across the entire data-set. This is provided by the argument 'addIds'. If 'addIds' is TRUE
the columns CruiseKey (identifying mission), Station (identifying station) and Fishstation (identifying fishstation or haul) are added in the same
manner that these fields are constructed when biotic data is converted to StoxBiotic (StoxBiotic
).
'FishStation' identifies station via serialnumber, which strictly speaking identifies a fishing operation,
but which is conventionally used to identify a station, since most stations have only one fishing operation.
'Station' is a similar unique identifier that identifies actual stations in data sets where the field 'station' is used to distinguish station from fishing operation.
In addition 'addIds' may add the columns 'CatchSample', 'Individual', 'Prey', 'Tag', 'AgeReading', 'PreyLengthBin', or 'PreyDevstageBin', which does not have a correspondance in StoxBiotic.