Skip to contents

Applies a function over the margins of an array-based FLCore class

Usage

# S4 method for FLArray,numeric,`function`
apply(X, MARGIN, FUN, ..., simplify = TRUE)

# S4 method for FLPar,ANY,ANY
apply(X, MARGIN, FUN, ..., simplify = TRUE)

# S4 method for FLQuantJK,numeric,`function`
apply(X, MARGIN, FUN, ..., simplify = TRUE)

# S4 method for FLParJK,numeric,`function`
apply(X, MARGIN, FUN, ..., simplify = TRUE)

Details

These methods call R's base::apply on an FLArray the standard arithmetic operators included in the Arith group ("+", "-", "*", `"^", "%%", "%/%", and "/"), so that they return an object of the appropriate class.

When the operation involves objects of two classes (e.g. FLPar and FLQuant), the class is the returned object is that of the more complexs object, in this case FLQuant.

See also

Author

The FLR Team

Examples


flq <- FLQuant(rlnorm(90), dim=c(3,10), units='kg')
flp <- FLPar(a=99)

# FLQuant and numeric
flq * 25
#> An object of class "FLQuant"
#> , , unit = unique, season = all, area = unique
#> 
#>      year
#> quant 1       2       3       4       5       6       7       8       9      
#>     1 14.0885 14.9662  6.3983 17.5206 52.5904 10.5750  9.7492 61.2581 93.9552
#>     2 75.6392 19.9283 85.2276 15.0173  4.7787 31.2725 18.3706 11.3174  6.3499
#>     3  5.2799 35.6988 12.1649 11.6934 11.4983 21.6870 44.4522  5.8776 10.8897
#>      year
#> quant 10     
#>     1 95.7868
#>     2 14.9923
#>     3  5.8320
#> 
#> units:  kg 
# Two FLQuant objects
flq + flq
#> An object of class "FLQuant"
#> , , unit = unique, season = all, area = unique
#> 
#>      year
#> quant 1       2       3       4       5       6       7       8       9      
#>     1 1.12708 1.19730 0.51187 1.40165 4.20723 0.84600 0.77994 4.90064 7.51641
#>     2 6.05113 1.59427 6.81820 1.20138 0.38229 2.50180 1.46965 0.90539 0.50799
#>     3 0.42239 2.85590 0.97319 0.93547 0.91986 1.73496 3.55618 0.47021 0.87118
#>      year
#> quant 10     
#>     1 7.66295
#>     2 1.19938
#>     3 0.46656
#> 
#> units:  kg