load_dietmatrix: Extract the dietmatrix from the biological parameterfile

Description Usage Arguments Value Examples

View source: R/load-dietmatrix.R

Description

Extracts the diet matrix as long dataframe from the biological paremeter file of any ATLANTIS simulation.

Usage

1
2
3
4
load_dietmatrix(prm_biol, fgs, transform = TRUE, convert_names = FALSE,
  version_flag = 2)

write_diet(dietmatrix, prm_biol, save_to_disc = TRUE)

Arguments

prm_biol

Character string giving the connection to the biological parameterfile. The filename usually contains biol_fishing and does end in .prm.

fgs

Character string giving the connection to the functional groups file. The filename usually contains Groups and does end in .csv.

transform

Boolean indicating if the returned dataframe is displayed in "long" (transform = TRUE, default) or "wide" (transform = FALSE) format. You should use the "wide" format in case you aim to change your diet matrix entries.

convert_names

Logical indicating if group codes are transformed to LongNames (TRUE) or not (default = FALSE).

version_flag

The version of ATLANTIS model. 1 for bec_dev, 2 for trunk. default is 2..

dietmatrix

Dataframe of the ATLANTIS dietmatrix generated with load_dietmatrix using transform = FALSE.

save_to_disc

Logical indicating if the resulting prm file should be overwritten (TRUE) or not (FALSE). Defaults to TRUE.

Value

dataframe of the availability matrix in long format with columns pred, pred_stanza (1 = juvenile, 2 = adult), prey_stanza, prey, avail, code.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Can be applied to trunk models.
d <- system.file("extdata", "setas-model-new-trunk", package = "atlantistools")
prm_biol <- file.path(d, "VMPA_setas_biol_fishing_Trunk.prm")
fgs <- file.path(d, "SETasGroupsDem_NoCep.csv")

dm <- load_dietmatrix(prm_biol, fgs)
head(dm, n = 10)

# Use write_diet to update your existing parameterfile.
dietmatrix <- load_dietmatrix(prm_biol, fgs, transform = FALSE)

# Write is set to FALSE here for technical reasons. Make sure to set it to TRUE in case you
# want to update your file.
new_diet <- write_diet(dietmatrix, prm_biol, save_to_disc = FALSE)

# And to bec-dev models.
d <- system.file("extdata", "setas-model-new-becdev", package = "atlantistools")
prm_biol <- file.path(d, "VMPA_setas_biol_fishing_New.prm")
fgs <- file.path(d, "SETasGroups.csv")

dm <- load_dietmatrix(prm_biol, fgs, version_flag = 1)
head(dm, n = 10)

atlantistools documentation built on Aug. 16, 2017, 9:05 a.m.