| codstom(doBy) | R Documentation |
Diet of Atlantic cod in the Gulf of St. Lawrence (Canada)
Description
Stomach content data for Atlantic cod (Gadus morhua) in the Gulf of St.Lawrence, Eastern Canada. Note: many prey items were of no interest for this analysis and were regrouped into the "Other" category.
Usage
data(codstom)
Format
A data frame with 10000 observations on the following 10 variables.
region- a factor with levels
SGSLNGSLrepresenting the southern and northern Gulf of St. Lawrence, respectively ship.type- a factor with levels
2331349099 ship.id- a factor with levels
115581171213614813688513690213732515122515193599433 trip- a factor with levels
1011121791999220012002080834567888995 set- a numeric vector
fish.id- a numeric vector
fish.length- a numeric vector, length in mm
prey.mass- a numeric vector, mass of item in stomach, in g
prey.type- a factor with levels
Ammodytes_spArgis_dentChion_opilDetritusEmptyEualus_fabEualus_macGadus_morHyas_aranHyas_coarLebbeus_groLebbeus_polLeptocl_macMallot_vilMegan_norvOphiuroideaOtherPaguridaePandal_borPandal_monPasiph_multSabin_septSebastes_spThem_abysThem_compThem_lib
Details
Cod are collected either by contracted commerical fishing vessels
(ship.type 90 or 99) or by research vessels. Commercial
vessels are identified by a unique ship.id.
Either
one research vessel or several commercial vessels conduct a survey
(trip), during which a trawl, gillnets or hooked lines are set
several times. Most trips are random stratified surveys (depth-based
stratification).
Each trip takes place within one of the regions. The
trip label is only guaranteed to be unique within a region and
the set label is only guaranteed to be unique within a
trip.
For each fish caught, the fish.length is recorded
and the fish is allocated a fish.id, but the fish.id
is only guaranteed to be unique within a set. A subset of the
fish caught are selected for stomach analysis (stratified random
selection according to fish length; unit of
stratification is the set for research surveys, the combination ship.id
and stratum for surveys conducted by commercial vessels, although strata
are not shown in codstom).
The basic experimental unit in this data set is a cod stomach
(one stomach per fish). Each stomach is uniquely identified by
a combination of region, ship.type, ship.id,
trip, set, and fish.id.
For each prey item found in a stomach,
the species and mass of the prey item are recorded, so there can be
multiple observations per stomach. There may also
be several prey items with the same prey.type in the one
stomach (for example many prey.types have been recoded Other,
which produced many instances of Other in the same stomach).
If a stomach is empty, a single observation is recorded
with prey.type
Empty and a prey.mass of zero.
Source
Small subset from a larger dataset (more stomachs, more variables, more
prey.types)
collected by D. Chabot and
M. Hanson,
Fisheries & Oceans Canada ([email protected]).
Examples
data(codstom)
str(codstom)
# removes multiple occurences of same prey.type in stomachs
codstom1 <- summaryBy(prey.mass ~
region+ship.type+ship.id+trip+set+fish.id+prey.type,
data = codstom, id = ~fish.length,
keep.names=TRUE, FUN = sum)
# keeps a single line per stomach with the total mass of stomach content
codstom2 <- summaryBy(prey.mass ~ region+ship.type+ship.id+trip+set+fish.id,
data = codstom, id = ~fish.length,
keep.names=TRUE, FUN = sum)
# mean prey mass per stomach for each trip
codstom3 <- summaryBy(prey.mass ~ region+ship.type+ship.id+trip,
data = codstom2, keep.names=TRUE, FUN = mean)
## Not run:
# wide version, one line per stomach, one column per prey type
library(reshape)
codstom4 <- melt(codstom, id = c(1:7, 9))
codstom5 <- cast(codstom4,
region+ship.type+ship.id+trip+set+fish.id+fish.length ~
prey.type, sum)
k <- length(names(codstom5))
prey_col <- 8:k
out <- codstom5[,prey_col]
out[is.na(out)] <- 0
codstom5[,prey_col] <- out
codstom5$total.content <- rowSums(codstom5[, prey_col])
## End(Not run)