Skip to contents

Use R's sweep method on FLCore classes

Usage

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

# S4 method for 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 object of class "FLQuant"
#> , , unit = unique, season = all, area = unique
#> 
#>      year
#> quant 1       2       3       4       5       6       7       8       9      
#>     1 0.23447 1.00000 0.66169 1.00000 0.37764 1.00000 1.00000 0.52301 0.53742
#>     2 0.85924 0.49154 0.96254 0.58859 1.00000 0.47852 0.12800 0.29560 1.00000
#>     3 1.00000 0.38721 1.00000 0.39603 0.42064 0.77241 0.54346 1.00000 0.74176
#>      year
#> quant 10     
#>     1 1.00000
#>     2 0.14132
#>     3 0.29221
#> 
#> units:  kg