
Extract numbers or biomass for a single species
Source:vignettes/articles/number-biomass-by-species.Rmd
number-biomass-by-species.Rmd
library(DATRASextra)
# select survey
survey <- "NS-IBTS"
# create temporary directory
tmp <- file.path(tempdir(), "DATRASextra")
dir.create(tmp, recursive = TRUE, showWarnings = FALSE)
# download data
download_datras(
surveys = survey,
years = 2021,
dir = tmp
)
# read in
surv0 <- read_datras(file.path(tmp, survey))
# clean data
surv <- clean_datras(surv0)
# subset for your species
surv <- subset(surv, Valid_Aphia == "126822") # Horse mackerelTo calculate total numbers and weight by haul, the information in the
HL table first needs to be raised to the haul level. A
convenient first step is to add numbers-at-length:
surv <- add_numbers_at_length(surv)This adds a matrix N to the HH table,
containing the estimated numbers in each length class for each haul. The
length classes can be modified with the cm_breaks or
by arguments.
The total number by haul can then be obtained by summing over length classes:
surv <- add_total_numbers_by_haul(surv)By default, this adds a single column HaulN to the
HH table. More generally, custom bins can be specified via
length_cuts. In that case, the result may contain separate
totals for broader user-defined length groups.
If species-specific length and weight information are available in
CA, or suitable length-weight relationships are available
in the species_info table, the numbers can also be
converted to weight:
surv <- add_total_weight_by_haul(surv)This adds HaulWgt to the HH table,
containing the total estimated weight by haul. As for abundance, custom
length-group summaries can be generated when length_cuts is
used.