migration_funs: Helper functions to create and format migration matrices

Description Usage Arguments Value Examples

Description

These functions create and format migration information for a Gadget stockfile. The migration_* functions create a data.frame with class of the same name as the function for use in check_stockfile_migration. The returned data.frame can then be read into format_migration which will return a list of the correct structure to be written to file. These functions will be most useful when migration proportions are not known and are specified as a switch in the Gadget model

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
migration_matrix(years, steps, areas, prop)

migration_ratios(years, steps, areas, prop)

format_migration(mig_matrix)

## S3 method for class 'migration_matrix'
format_migration(mig_matrix)

## S3 method for class 'migration_ratios'
format_migration(mig_ratios)

Arguments

years

Numeric vector of years to specify migration proportions for

steps

Numeric vector of steps to specify migration proportions for

areas

Numeric vector of areas in the Gadget model

prop

Vector of proportions to use. Can be numeric or character. Length must be the same as years * steps * areas^2 or a factor of such (or 1)

mig_matrix

A data.frame of class "migration_matrix" as produced by migration_matrix

A

data.frame of class "migration_ratios" as produced by migration_ratios

Value

migration_* functions return a data.frame with class the same as the function name. format_migration_matrix returns a list with each element a matrix or data.frame of the migration ratios to be used

Examples

1
2
3
4
5
6
7
8
years <- 1:2
steps <- 1:2
areas <- 1:2
ysa_combo <- c(paste(years, steps, sep = "."),
               paste(rev(years),
               steps, sep = "."))
prop <- sort(rep(paste("#cod.migration", ysa_combo, sep = "."), 4))
migration_matrix(years, steps, areas, prop)

inspktrgadget/gadgetSim documentation built on May 10, 2019, 9:51 a.m.