aggregateDensityData: Aggregate and select density data from Atlantis output

View source: R/aggregateDensityData.R

aggregateDensityDataR Documentation

Aggregate and select density data from Atlantis output

Description

subsets data based on defined columns, and takes median over layers, but enter NA for layers to keep the column names the same. Currently, the function works for a vector of defined species and polygons.

Usage

aggregateDensityData(
  dat,
  time,
  species,
  boxes,
  keepColumns = c("species", "agecl", "polygon", "time")
)

Arguments

dat

A data.frame of density data (structn, resn) from reading in the Atlantis output

time

A single value or a vector of time steps for a survey. Time steps are specified as integers.

species

A vector of character values, where each entry is a species name that is sampled in the survey.

boxes

A vector of polygons where the survey samples within each specified polygon.

keepColumns

A vector of character values, specifying which columns to keep for the returned data.frame. The default is c("species", "agecl", "polygon", "time").

Value

The function returns a subsetted matrix with the same columns as the input data, i.e.,:

  • species

  • agecl

  • polygon

  • layer

  • time

  • atoutput

Author(s)

Sarah Gaichas, Allan Hicks

Examples

dat <- data.frame(species = c(rep("spec1", 3*3),rep("spec2", 5*3)),
  agecl = c(rep(1:3, 3), rep(3:7, 3)),
  polygon = c(rep(1:3, each = 3), rep(1:3, each = 5)),
  layer = 1, time = 1)
dat$atoutput <- 10000/dat$agecl
tmp <- aggregateData(dat = dat, time = 1,
  species = c("spec1", "spec2"), boxes = 1:2)
rm(list = c("tmp", "dat"))


r4atlantis/atlantisom documentation built on Nov. 12, 2023, 2:59 a.m.