Skip to contents

Sums the overlap according to specified strata with species always included by default. Overlap is assumed to be calculated from a call to get_overlap.

Usage

aggregate_overlap(object, ...)

# S3 method for class 'tbl_df'
aggregate_overlap(object, ...)

# S3 method for class 'data.frame'
aggregate_overlap(object, ...)

Arguments

object

A tibble or data.frame object containing overlap values and grouping strata. Columns containing overlap data should have a "overlap_" prefix (e.g. overlap_diw).

...

Grouping strata, typically fishery group.

Value

An object of class class(object), with the overlap (overlap) summed per species code per strata.

Examples

library(sefraInputs)
library(dplyr)
x <- data.frame(id_fishery_group = rep(1:2, each = 10), id_period = rep(1:3, length = 20), overlap_diw = runif(20), overlap_prk = runif(20))
x %>% aggregate_overlap(id_fishery_group)
#>   code id_fishery_group  overlap
#> 1  DIW                1 4.439794
#> 2  DIW                2 3.833615
#> 3  PRK                1 5.587649
#> 4  PRK                2 4.157534
x %>% aggregate_overlap(id_fishery_group, id_period)
#>    code id_fishery_group id_period   overlap
#> 1   DIW                1         1 1.5082575
#> 2   DIW                1         2 1.1314997
#> 3   DIW                1         3 1.8000364
#> 4   DIW                2         1 0.6186125
#> 5   DIW                2         2 2.5740723
#> 6   DIW                2         3 0.6409303
#> 7   PRK                1         1 1.2258513
#> 8   PRK                1         2 2.1891326
#> 9   PRK                1         3 2.1726650
#> 10  PRK                2         1 0.9133408
#> 11  PRK                2         2 1.5910297
#> 12  PRK                2         3 1.6531637