Applies a function over the margins of an array-based FLCore class
# S4 method for FLArray,numeric,`function` apply(X, MARGIN, FUN, ...) # S4 method for FLPar,ANY,ANY apply(X, MARGIN, FUN, ...) # S4 method for FLQuantJK,numeric,`function` apply(X, MARGIN, FUN, ...) # S4 method for FLParJK,numeric,`function` apply(X, MARGIN, FUN, ...)
These methods call R's base::apply on an FLArray the standard arithmetic operators included in the
Arith
group ("+", "-", "*", `"^", "
"/"), 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
.
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 #> 1 6.1647 24.8611 4.0433 18.8435 197.1374 3.8801 43.0289 35.9391 #> 2 32.2718 46.5454 19.5222 14.3705 4.8934 14.8331 10.0222 6.7824 #> 3 2.1850 78.8295 19.5833 46.8925 41.7334 23.7189 39.9261 52.2820 #> year #> quant 9 10 #> 1 165.2370 24.6044 #> 2 22.6788 10.9363 #> 3 9.8063 5.5095 #> #> 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 #> 1 0.49317 1.98889 0.32346 1.50748 15.77099 0.31041 3.44231 2.87513 #> 2 2.58174 3.72363 1.56177 1.14964 0.39147 1.18665 0.80177 0.54259 #> 3 0.17480 6.30636 1.56666 3.75140 3.33868 1.89752 3.19409 4.18256 #> year #> quant 9 10 #> 1 13.21896 1.96835 #> 2 1.81430 0.87490 #> 3 0.78451 0.44076 #> #> units: kg