Skip to contents

Use R's sweep method on FLCore classes

Usage

# S4 method for class 'FLArray'
sweep(x, MARGIN, STATS, FUN = "-", check.margin = TRUE, ...)

# S4 method for class 'FLPar'
sweep(x, MARGIN, STATS, FUN = "-", check.margin = TRUE, ...)

Details

These methods call base R sweep method on FLCore classes and then ensure that the returned object is of same class.

Generic function

sweep(x, MARGIN, STATS, FUN = "-", check.margin = TRUE, ...)

See also

Author

The FLR Team

Examples


flq <- FLQuant(rlnorm(90), dim=c(3,10), units='kg')
# Get ratio of max value by year
sweep(flq, 2, apply(flq, 2, max), "/")
#> An x of class "FLQuant"
#> , , unit = unique, season = all, area = unique
#> 
#>      year
#> quant 1     2     3     4     5     6     7     8     9     10   
#>     1 0.234 1.000 0.662 1.000 0.378 1.000 1.000 0.523 0.537 1.000
#>     2 0.859 0.492 0.963 0.589 1.000 0.479 0.128 0.296 1.000 0.141
#>     3 1.000 0.387 1.000 0.396 0.421 0.772 0.543 1.000 0.742 0.292
#> 
#> units:  kg